woocommerce / woocommerce-gateway-paypal-express-checkout

58 stars 65 forks source link

Overriding templates in PayPal Express Checkout #825

Closed csalmeida closed 3 years ago

csalmeida commented 3 years ago

Describe the bug

This is a question and not a bug, I thought this could be the right place to add it in so more people can reference to it in the future.

I have been working with the Woo Commerce plug-in which allows to override its templates by placing a new version of them in a /woocommerce folder at the directory of a theme.

However I can't seem to do the same when I need to override markup for this particular plug-in. Am I missing something? I noticed that markup is directly built in classes which is slightly different to how Woo Commerce arranges it with templates.

I am considering creating a copy of the plug-in and add my own overrides but as I understand this comes at a cost of future updates.

For context no layout plugins like Div or Elementor are being used, this is a theme written from scratch that makes use of .twig templates.

Any thoughts or information on how to go about this would be deeply appreciated.

To reproduce

  1. Create a folder name woocommerce-gateway-paypal-express-checkout in your theme directory
  2. Copy one of the plug-ins files into the folder e.g includes/class-wc-gateway-ppec-plugin.php
  3. Change a value in the file that gets echoed to the page.
  4. Refreshing should not show the updated value.

Screenshots

Expected behavior

The new value should show on the page? (not actually sure if this should happen but it was what I expected)

Environment (please complete the following information):

Additional details

System status ``` ```
csalmeida commented 3 years ago

Further discussion on the topic:

jorgeatorres commented 3 years ago

Hi @csalmeida!

PayPal Checkout doesn't provide any templates that can be overridden. That's because all we do is integrate with the regular single product, cart & checkout pages to display the PayPal button (or the other funding methods). Even the look of those buttons is determined by PayPal scripts, so can't really be controlled via an override (or CSS).

That said, depending on what you're trying to do, there might be a way to do it using only hooks (actions or filters), which are provided by WooCommerce and it's what PayPal Checkout uses to integrate with things.

If you still have the need to override certain aspects of the extension and have specific questions on how to do a particular kind of override, let us know and we'll try to provide some guidance.