mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
Merge pull request #1655 from woocommerce/PCP-1971-product-page-pp-button-keep-loading-popup-wc-add-to-cart-params-is-not-defined-error-in-woo-commerce
Product page PP button keep loading popup - "wc_add_to_cart_params is not defined" error in WooCommerce (1971)
This commit is contained in:
commit
957016d2a3
1 changed files with 11 additions and 2 deletions
|
@ -2,10 +2,19 @@ class CartHelper {
|
||||||
|
|
||||||
constructor(cartItemKeys = [])
|
constructor(cartItemKeys = [])
|
||||||
{
|
{
|
||||||
this.endpoint = wc_cart_fragments_params.wc_ajax_url.toString().replace('%%endpoint%%', 'remove_from_cart');
|
|
||||||
this.cartItemKeys = cartItemKeys;
|
this.cartItemKeys = cartItemKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getEndpoint() {
|
||||||
|
let ajaxUrl = "/?wc-ajax=%%endpoint%%";
|
||||||
|
|
||||||
|
if ((typeof wc_cart_fragments_params !== 'undefined') && wc_cart_fragments_params.wc_ajax_url) {
|
||||||
|
ajaxUrl = wc_cart_fragments_params.wc_ajax_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ajaxUrl.toString().replace('%%endpoint%%', 'remove_from_cart');
|
||||||
|
}
|
||||||
|
|
||||||
addFromPurchaseUnits(purchaseUnits) {
|
addFromPurchaseUnits(purchaseUnits) {
|
||||||
for (const purchaseUnit of purchaseUnits || []) {
|
for (const purchaseUnit of purchaseUnits || []) {
|
||||||
for (const item of purchaseUnit.items || []) {
|
for (const item of purchaseUnit.items || []) {
|
||||||
|
@ -46,7 +55,7 @@ class CartHelper {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch(this.endpoint, {
|
fetch(this.getEndpoint(), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials: 'same-origin',
|
credentials: 'same-origin',
|
||||||
body: params
|
body: params
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue