Reputation: 899
Follow up to my previous question WooCommerce use Secondary PHP File (Recalling Template)
The function below is a secondary add to cart function for my website which calls a secondary php template for grouped products, the problem is it will only work if the modified template is actually inside the woocommerce plugin templates folder.
This is not good as any updates to woocommerce will delete my template. The problem is the third line "wc_get_template" this function will only work for me if the template is in the woocommerce plugins templates folder. When I need it to call the template from my child theme folder "custom-groups" folder.
Does anyone know how I can make this function fetch the template from a folder other than the plugin templates folder?
I have tried various techniques as you can see from my previous question but with no luck.
When I try to add this custom template inside my woocommerce folders in my child theme the template doesn't work for some reason I think the problem is because it is not overwritting an original template....
function woocommerce_grouped_add_to_cart2() {
global $product;
wc_get_template( 'single-product/add-to-cart/grouped-simfree.php', array(
'grouped_product' => $product,
'grouped_products' => $product->get_children(),
'quantites_required' => false
) );
}
function woo_simfree_product_tab_content() {
woocommerce_grouped_add_to_cart2();
}
Upvotes: 10
Views: 22577
Reputation: 61
wc_get_template( 'single-product/add-to-cart/grouped-simfree.php', array(
'grouped_product' => $product,
'grouped_products' => $product->get_children(),
'quantites_required' => false
), '', _YOU_PLUGIN_TEMPLATES_PATH_ );
Upvotes: 6
Reputation: 65284
create a folder named woocommerce
in your theme... this folder is the equivalent of woocommerce/templates
folder in the plugin... wc_get_template
will look for the file in woocommerce
folder in your theme... if not found, it will look into the plugin's templates folder...
you can find more information here..
Upvotes: 5