Clicky

  1. Home
  2. Extension & Themes
  3. WooCommerce
  4. How to Override V3 Layout product templates in AMP.

How to Override V3 Layout product templates in AMP.

If you are trying to override specific product templates of AMP Woocommerce Pro plugin then you need to follow these below instructions.

In Amp WooCommerce Pro plugin we are using “wc_get_template” filter to override the product templates of WooCommerce at a priority of 10 so by using the same filter “wc_get_template” you can override our templates in the amp but you have to use the priority of the filter higher than 10 to override.

add_filter('wc_get_template','ampforwp_woocommerce_template_override',10,5);

Below is an example of how to override a template.

let’s override the quantity-input template using a custom plugin or you can do it in your theme functions.php file.

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;

add_filter('wc_get_template','override_ampwcpro_woocommerce_templates',20,5);


function override_ampwcpro_woocommerce_templates($template, $template_name, $args, $template_path, $default_path){
  if($template_name == 'global/quantity-input.php'){
	  $template = plugin_dir_path(__FILE__).'custom_template/quantity-input.php';
	 }
   return $template;

}

As you can see in the above code we have added a filter with priority 20 which is higher than 10 to override.

And in the function, as we are overriding quantity-input file so we are checking that and then giving the customized template path.

If you want to download the above example custom plugin Click Here.

Before overriding the quantity-input template in AMP

The output after overriding quantity-input template in AMP

That’s it for this tutorial!

We hope it helped you. If you have any feedback or questions, then please share them in the comments section below.

Ask your Questions Directly!
If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!
Updated on February 8, 2020

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support

Leave a Comment