mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-08 21:52:55 +08:00
Merge remote-tracking branch 'origin/PCP-2006-google-pay-settings-improvements' into PCP-2006-google-pay-settings-improvements
This commit is contained in:
commit
2bbdb28388
18 changed files with 298 additions and 116 deletions
|
@ -483,7 +483,7 @@ class SmartButton implements SmartButtonInterface {
|
|||
echo '<p class="woocommerce-mini-cart__buttons buttons">';
|
||||
echo '<span id="ppc-button-minicart"></span>';
|
||||
do_action( 'woocommerce_paypal_payments_minicart_button_render' );
|
||||
echo '</div>';
|
||||
echo '</p>';
|
||||
},
|
||||
30
|
||||
);
|
||||
|
@ -964,6 +964,10 @@ class SmartButton implements SmartButtonInterface {
|
|||
// phpcs:ignore WordPress.WP.I18n
|
||||
'shipping_field' => _x( 'Shipping %s', 'checkout-validation', 'woocommerce' ),
|
||||
),
|
||||
'simulate_cart' => array(
|
||||
'enabled' => apply_filters( 'woocommerce_paypal_payments_simulate_cart_enabled', true ),
|
||||
'throttling' => apply_filters( 'woocommerce_paypal_payments_simulate_cart_throttling', 5000 ),
|
||||
),
|
||||
'order_id' => 'pay-now' === $this->context() ? $this->get_order_pay_id() : 0,
|
||||
'single_product_buttons_enabled' => $this->settings_status->is_smart_button_enabled_for_location( 'product' ),
|
||||
'mini_cart_buttons_enabled' => $this->settings_status->is_smart_button_enabled_for_location( 'mini-cart' ),
|
||||
|
|
|
@ -151,6 +151,7 @@ class SimulateCartEndpoint extends AbstractCartEndpoint {
|
|||
|
||||
/**
|
||||
* Restores the real cart.
|
||||
* Currently, unsets the WC cart to prevent race conditions arising from it being persisted.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -158,10 +159,17 @@ class SimulateCartEndpoint extends AbstractCartEndpoint {
|
|||
// Remove from cart because some plugins reserve resources internally when adding to cart.
|
||||
$this->remove_cart_items();
|
||||
|
||||
// Restore cart and unset cart clone.
|
||||
if ( null !== $this->real_cart ) {
|
||||
WC()->cart = $this->real_cart;
|
||||
if ( apply_filters( 'woocommerce_paypal_payments_simulate_cart_prevent_updates', true ) ) {
|
||||
// Removes shutdown actions to prevent persisting session, transients and save cookies.
|
||||
remove_all_actions( 'shutdown' );
|
||||
unset( WC()->cart );
|
||||
} else {
|
||||
// Restores cart, may lead to race conditions.
|
||||
if ( null !== $this->real_cart ) {
|
||||
WC()->cart = $this->real_cart;
|
||||
}
|
||||
}
|
||||
|
||||
unset( $this->cart );
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue