mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Fix ApplePay product page variants
This commit is contained in:
parent
3d293058fb
commit
889df4d88c
3 changed files with 14 additions and 15 deletions
|
@ -33,20 +33,7 @@ class ApplepayButton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//PRODUCT DETAIL PAGE
|
|
||||||
this.refreshContextData();
|
this.refreshContextData();
|
||||||
|
|
||||||
if (this.context === 'product') {
|
|
||||||
jQuery(document).on('appleclick', () => {
|
|
||||||
(this.onshippingcontactselected())({
|
|
||||||
shippingContact: {
|
|
||||||
locality: 'New York',
|
|
||||||
postalCode: '10001',
|
|
||||||
countryCode: 'US'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init(config) {
|
init(config) {
|
||||||
|
|
|
@ -254,6 +254,7 @@ class ApplePayDataObjectHttp {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data = $this->append_products_to_data( $data, $_POST );
|
||||||
$data = $this->preprocess_request_data( $data );
|
$data = $this->preprocess_request_data( $data );
|
||||||
|
|
||||||
$data[ PropertiesDictionary::CALLER_PAGE ] = $caller_page;
|
$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 ) {
|
if ( $products ) {
|
||||||
$data[ PropertiesDictionary::PRODUCTS ] = $products;
|
$data[ PropertiesDictionary::PRODUCTS ] = $products;
|
||||||
|
|
|
@ -78,7 +78,7 @@ class CartProductsHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
foreach ( $data['products'] as $product ) {
|
foreach ( $data['products'] as $product ) {
|
||||||
$product = $this->products_from_data( $product );
|
$product = $this->product_from_data( $product );
|
||||||
if ( $product ) {
|
if ( $product ) {
|
||||||
$products[] = $product;
|
$products[] = $product;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue