mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
PCP-20 / show buttons when products_page shortcode is used
This commit is contained in:
parent
329e2a47a0
commit
93d70249c7
1 changed files with 21 additions and 19 deletions
|
@ -52,6 +52,10 @@ class SmartButton implements SmartButtonInterface
|
|||
{
|
||||
|
||||
$buttonRenderer = static function () {
|
||||
$product = wc_get_product();
|
||||
if ($product->is_type(['external', 'grouped'])) {
|
||||
return;
|
||||
}
|
||||
echo '<div id="ppc-button"></div>';
|
||||
};
|
||||
|
||||
|
@ -60,6 +64,10 @@ class SmartButton implements SmartButtonInterface
|
|||
if (! $canRenderDcc) {
|
||||
return;
|
||||
}
|
||||
$product = wc_get_product();
|
||||
if ($product->is_type(['external', 'grouped'])) {
|
||||
return;
|
||||
}
|
||||
if (!$id) {
|
||||
$id = 'ppcp-hosted-fields';
|
||||
}
|
||||
|
@ -108,32 +116,26 @@ class SmartButton implements SmartButtonInterface
|
|||
$notEnabledOnProductPage = $this->settings->has('button_single_product_enabled') &&
|
||||
!$this->settings->get('button_single_product_enabled');
|
||||
if (
|
||||
is_product()
|
||||
(is_product() || wc_post_content_has_shortcode('product_page'))
|
||||
&& !$notEnabledOnProductPage
|
||||
) {
|
||||
$product = wc_get_product();
|
||||
if (! $product->is_type(['external', 'grouped'])) {
|
||||
add_action(
|
||||
'woocommerce_single_product_summary',
|
||||
$buttonRenderer,
|
||||
31
|
||||
);
|
||||
}
|
||||
}
|
||||
if (
|
||||
is_product()
|
||||
(is_product() || wc_post_content_has_shortcode('product_page'))
|
||||
&& $this->settings->has('dcc_single_product_enabled')
|
||||
&& $this->settings->get('dcc_single_product_enabled')
|
||||
) {
|
||||
$product = wc_get_product();
|
||||
if (! $product->is_type(['external', 'grouped'])) {
|
||||
add_action(
|
||||
'woocommerce_single_product_summary',
|
||||
$dccRenderer,
|
||||
31
|
||||
);
|
||||
}
|
||||
}
|
||||
$notEnabledOnMiniCart = $this->settings->has('button_mini_cart_enabled') &&
|
||||
!$this->settings->get('button_mini_cart_enabled');
|
||||
if (
|
||||
|
@ -308,7 +310,7 @@ class SmartButton implements SmartButtonInterface
|
|||
private function context(): string
|
||||
{
|
||||
$context = 'mini-cart';
|
||||
if (is_product()) {
|
||||
if (is_product() || wc_post_content_has_shortcode('product_page')) {
|
||||
$context = 'product';
|
||||
}
|
||||
if (is_cart()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue