Add ButtonModuleWatcher

Adjustments for APM support
This commit is contained in:
Pedro Silva 2023-08-29 15:26:59 +01:00
parent e7e5ebde4e
commit 93afeeba68
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
6 changed files with 59 additions and 14 deletions

View file

@ -480,11 +480,10 @@ class SmartButton implements SmartButtonInterface {
return;
}
echo '<p
id="ppc-button-minicart"
class="woocommerce-mini-cart__buttons buttons"
></p>';
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>';
},
30
);

View file

@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\Button\Endpoint;
use Exception;
use Psr\Log\LoggerInterface;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Money;
use WooCommerce\PayPalCommerce\Button\Assets\SmartButton;
/**
@ -100,18 +101,25 @@ class SimulateCartEndpoint extends AbstractCartEndpoint {
$button_enabled = $button_enabled && ! $this->smart_button->is_button_disabled( 'product', $context_data );
}
$base_location = wc_get_base_location();
$shop_country_code = $base_location['country'];
$currency_code = get_woocommerce_currency();
wp_send_json_success(
array(
'total' => $total,
'funding' => array(
'total' => $total,
'total_str' => ( new Money( $total, $currency_code ) )->value_str(),
'currency_code' => $currency_code,
'country_code' => $shop_country_code,
'funding' => array(
'paylater' => array(
'enabled' => $pay_later_enabled,
),
),
'button' => array(
'button' => array(
'is_disabled' => ! $button_enabled,
),
'messages' => array(
'messages' => array(
'is_hidden' => ! $pay_later_messaging_enabled,
),
)