Home Forums WoodMart support forum Product Layout Hooks

Product Layout Hooks

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #569700

    Mike
    Participant

    Hi,
    i have construct a custom plugin to hide add to cart button and prices conditionally and everything is working fine. But my code is stop working if i enable a custom layout for product page.
    Can you tell me what action should i use so my code will function with custom product layout?

    Here is a part of my code that is working when custom product layout is disabled.

    /** Modify product page when non-purchasable or hide price & cart are enabled: hide price and/or add to cart button */
    add_action('woocommerce_before_single_product', 'gb_npwp_modify_product_display');
    function gb_npwp_modify_product_display() {
        global $product;
    
        $not_buyable = get_post_meta($product->get_id(), '_not_buyable', true);
        $hide_price = get_post_meta($product->get_id(), '_hide_price', true);
    
        if ($not_buyable === 'yes' || $hide_price === 'yes') {
            remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
            if ($hide_price === 'yes') {
                remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);
            }
        }
    }
    #569893

    Hung Pham
    Keymaster

    Hi Mike,

    Unfortunately, customization is out of basic support.

    Thanks for understanding our limitations.

    Regards,

    #569910

    Mike
    Participant

    Well if the customization is out of basic support, then you must listen to and implement major features request that needed and a considered e-commerce oriented theme should have. But anyway.

    i don’t asked you to customize something for me. I just asked you what are the hooks that woodmart use to override the default woocommerce product template, because i need to use that action on my code. Is this clear to you?

    #570299

    Hung Pham
    Keymaster

    Hi Mike,

    First of all, I’m really sorry have taken long time to reply you due to the weekend.

    In order for the custom code to work, you need to add 2 Hook elements to the single product layout, select woocommerce_before_single_product in one and woocommerce_single_product_summary in the other. Also, in the configuration of these elements, you need to turn off the Clean actions option, and not use the Add to cart element, since it will be displayed using a hook.

    Please refer to our documentation and let me know how it goes https://xtemos.com/docs-topic/custom-hooks-and-plugins-compatibility/

    Regards,

Viewing 4 posts - 1 through 4 (of 4 total)