Skip to content

Instantly share code, notes, and snippets.

@InpsydeNiklas
Last active November 25, 2023 14:24
Show Gist options
  • Save InpsydeNiklas/202837609318f9c0e827c382787147b0 to your computer and use it in GitHub Desktop.
Save InpsydeNiklas/202837609318f9c0e827c382787147b0 to your computer and use it in GitHub Desktop.
move PayPal button on product page below add to cart form
add_filter('woocommerce_paypal_payments_single_product_renderer_hook', function() {
return 'woocommerce_after_add_to_cart_form';
});
@telemarker
Copy link

thanks a lot!

@ahmedzeidan
Copy link

Works well with Elementor since the PayPal Payments plugin does not show the PP button on Elementor Product pages.

Thanks, @InpsydeNiklas Would love to see better integration with Elementor in the future!

@InpsydeNiklas
Copy link
Author

For reasons I can't disclose, originally, the decision was made to use the woocommerce_single_product_summary hook. This is different from the previously popular PayPal integration and while it works in most cases, there can be issues with certain page builders or themes as the feedback on this gist suggests.

There are other ways to work around this from the Elementor plugin point of view, but the PayPal Payments render hooks were introduced, in part, to provide an easy-to-apply solution for problems of this kind.
Changing defaults can be a dicey topic as these impact (almost) all users, and this item is fairly low on the to-do list, but I wouldn't rule it out. Please don't get me wrong, but I'd also like to point out that I'm not seeing anything that prevents Elementor from providing dedicated compatibility with PayPal Payments 😇 @ahmedzeidan

@ahmedzeidan
Copy link

Thanks @InpsydeNiklas for the detailed explanation, maybe a workaround in the future is to add an optional shortcode that can be inserted easily with Elementor or other page builders. Just a suggestion.

The snippet works well for me and all is good. Thanks for the great work provided to this great plugin, it has improved a lot.

@InpsydeNiklas
Copy link
Author

In version 2.1.0 and newer, this filter was implemented in the core plugin and activates automatically either when Divi is the active (parent) theme or the Elementor Pro plugin is active: woocommerce/woocommerce-paypal-payments#1254

So there may be a small number of users that suddenly notice a slight change in the button placement on the single product page if they have the Elementor Pro plugin active, but don't actually use it to build a custom single product page.

There may still be other page builders or custom themes which would still benefit from manually adding the filter. But the majority of reports about incorrect button placement on single product should ideally be resolved by this.

@Triloworld
Copy link

Triloworld commented Aug 14, 2023

@InpsydeNiklas

But the majority of reports about incorrect button placement on single product should ideally be resolved by this.

Majority is #1 Gutenberg + FSE and it isn't show properly ;/ Add option to enable this in panel as placement adjust so anybody can easily use that change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment