Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce function wc_get_template() modification

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();
} 
like image 510
mitchelangelo Avatar asked Feb 16 '16 10:02

mitchelangelo


1 Answers

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_ );
like image 52
KAA-lab Avatar answered Sep 19 '22 12:09

KAA-lab