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.
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.
If you want to add an AWeber form in AMP then first you need to…
Webpushr is the fastest growing web push notifications platform that marketers love & developers rely…
Follow these steps to add Adobe Analytics in AMP Step 1: Go to WordPress Admin Area -> AMP…
Core Web Vitals are the subset of Web Vitals that apply to all web pages,…
The following reasons can be shown for non-indexing. Server error (5xx) Your server returned a 500-level…
We have added the Google Analytics 4 ( GA 4 ) integration in AMPforWP v1.0.80.…