Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sync): remove localized number format #3434

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions includes/reader-activation/sync/class-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private static function get_order_metadata( $order, $payment_page_url = false )
}
$order_date_paid = $order->get_date_paid();
if ( $payment_received && ! empty( $order_date_paid ) ) {
$metadata['last_payment_amount'] = \wc_format_localized_price( $order->get_total() );
$metadata['last_payment_amount'] = $order->get_total();
$metadata['last_payment_date'] = $order_date_paid->date( Metadata::DATE_FORMAT );
}

Expand Down Expand Up @@ -270,7 +270,7 @@ private static function get_order_metadata( $order, $payment_page_url = false )
$metadata['recurring_payment'] = $current_subscription->get_total();

if ( $payment_received ) {
$metadata['last_payment_amount'] = \wc_format_localized_price( $current_subscription->get_total() );
$metadata['last_payment_amount'] = $current_subscription->get_total();
$metadata['last_payment_date'] = $current_subscription->get_date( 'last_order_date_paid' ) ? $current_subscription->get_date( 'last_order_date_paid' ) : gmdate( Metadata::DATE_FORMAT );
}

Expand Down Expand Up @@ -322,7 +322,7 @@ public static function get_contact_from_customer( $customer, $payment_page_url =

$metadata['account'] = $customer->get_id();
$metadata['registration_date'] = $customer->get_date_created()->date( Metadata::DATE_FORMAT );
$metadata['total_paid'] = \wc_format_localized_price( $customer->get_total_spent() );
$metadata['total_paid'] = $customer->get_total_spent();

$order = self::get_current_product_order_for_sync( $customer );

Expand Down
3 changes: 0 additions & 3 deletions tests/mocks/wc-mocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ public function get_status() {
function wc_create_order( $data ) {
return new WC_Order( $data );
}
function wc_format_localized_price( $price ) {
return '$' . $price;
}
function wc_get_checkout_url() {
return 'https://example.com/checkout';
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit-tests/reader-activation-sync-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function test_payment_metadata_basic() {
'payment_page' => $payment_page_url,
'membership_status' => 'customer',
'product_name' => '',
'last_payment_amount' => '$' . $order_data['total'],
'last_payment_amount' => $order_data['total'],
'last_payment_date' => $today,
'payment_page_utm_source' => 'test_source',
'payment_page_utm_medium' => '',
Expand All @@ -116,7 +116,7 @@ public function test_payment_metadata_basic() {
'billing_cycle' => '',
'recurring_payment' => '',
'next_payment_date' => '',
'total_paid' => '$' . ( self::USER_DATA['meta_input']['wc_total_spent'] + $order_data['total'] ),
'total_paid' => self::USER_DATA['meta_input']['wc_total_spent'] + $order_data['total'],
'account' => self::$user_id,
'registration_date' => $today,
],
Expand Down Expand Up @@ -182,7 +182,7 @@ public function test_payment_metadata_from_customer() {
self::$current_order = $order;

$contact_data = Sync\WooCommerce::get_contact_from_customer( self::$user_id );
$this->assertEquals( '$' . $order_data['total'], $contact_data['metadata']['last_payment_amount'] );
$this->assertEquals( $order_data['total'], $contact_data['metadata']['last_payment_amount'] );
$this->assertEquals( gmdate( 'Y-m-d' ), $contact_data['metadata']['last_payment_date'] );
}

Expand All @@ -208,7 +208,7 @@ public function test_payment_metadata_from_customer_with_last_order_failed() {
];
$order = \wc_create_order( $failed_order_data );
$contact_data = Sync\WooCommerce::get_contact_from_customer( self::$user_id );
$this->assertEquals( '$' . $completed_order_data['total'], $contact_data['metadata']['last_payment_amount'] );
$this->assertEquals( $completed_order_data['total'], $contact_data['metadata']['last_payment_amount'] );
$this->assertEquals( $completed_order_data['date_paid'], $contact_data['metadata']['last_payment_date'] );
}
}