PCP-20 / show buttons when products_page shortcode is used

This commit is contained in:
David Remer 2020-07-10 10:07:00 +03:00
parent 329e2a47a0
commit 93d70249c7

View file

@ -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()) {