Fix ApplePay product page variants

This commit is contained in:
Pedro Silva 2023-10-25 18:40:36 +01:00
parent 3d293058fb
commit 889df4d88c
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
3 changed files with 14 additions and 15 deletions

View file

@ -33,20 +33,7 @@ class ApplepayButton {
}
}
//PRODUCT DETAIL PAGE
this.refreshContextData();
if (this.context === 'product') {
jQuery(document).on('appleclick', () => {
(this.onshippingcontactselected())({
shippingContact: {
locality: 'New York',
postalCode: '10001',
countryCode: 'US'
}
});
});
}
}
init(config) {

View file

@ -254,6 +254,7 @@ class ApplePayDataObjectHttp {
return;
}
$data = $this->append_products_to_data( $data, $_POST );
$data = $this->preprocess_request_data( $data );
$data[ PropertiesDictionary::CALLER_PAGE ] = $caller_page;
@ -697,7 +698,18 @@ class ApplePayDataObjectHttp {
)
);
$products = json_decode( wp_unslash( $_POST[ PropertiesDictionary::PRODUCTS ] ?? '' ), true );
return $this->append_products_to_data( $data, $_POST );
}
/**
* Appends product to a data array.
*
* @param array $data The data.
* @param array $request_data The request data.
* @return array
*/
public function append_products_to_data( array $data, array $request_data ): array {
$products = json_decode( wp_unslash( $request_data[ PropertiesDictionary::PRODUCTS ] ?? '' ), true );
if ( $products ) {
$data[ PropertiesDictionary::PRODUCTS ] = $products;