• Resolved Vikas Khunteta

    (@vikas_khunteta)


    Hi, thanks for the plugin.

    The issue you fixed in version 12.6 June 14 2018 actually created problem for me. I have been using the woocommerce_before_add_to_cart_button hook to load all type of custom fields into bootstrap modal.

    I removed below hooks using remove_action hook to fix the problem

    // Rendering fields on product page
    add_action ( 'woocommerce_before_add_to_cart_button', 'ppom_woocommerce_show_fields', 15);
    add_action ( 'woocommerce_single_variation', 'ppom_woocommerce_show_fields', 15);

    Earlier you used only woocommerce_before_add_to_cart_button hook to render fields but in this version you used both hooks which is available on the variable.php file into woocommerce template. That’s the main reason of fields duplication.

    Please remove below hook from plugin.class.php file.

    add_action ( 'woocommerce_single_variation', 'ppom_woocommerce_show_fields', 15);

    Also remove below code from woocommerce.php file from your plugin

    // @Reason: variable product render fields twice. To stop this we add following code.
    if( $product->get_type() == 'variable' && current_filter() == 'woocommerce_before_add_to_cart_button') {
        return;
    }

    At the moment, I have been commenting above code due to problem in my case. Removing woocommerce_single_variation hook with above code will fix the problem for all users not just me.

    • This topic was modified 6 years, 5 months ago by Vikas Khunteta.
    • This topic was modified 6 years, 5 months ago by Vikas Khunteta. Reason: formatting
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Vikas,

    thanks for this. But we have been getting many request where fields were showing duplicate on variable products and when we investigate issue we found that some/mostly themes do not placing this hook woocommerce_before_add_to_cart_button correctly and and it was creating issue. So after many struggle we add to hooks

    woocommerce_before_add_to_cart_button
    it only load ppom fields on simple products

    woocommerce_single_variation
    will load ppom fields on variable products

    Thread Starter Vikas Khunteta

    (@vikas_khunteta)

    Hi again,

    Can you use hook priorityor something else into this condition so when high priority hook used then the below condition fails and it continues further.

    // @Reason: variable product render fields twice. To stop this we add following code.
    if( $product->get_type() == 'variable' && current_filter() == 'woocommerce_before_add_to_cart_button') {
        return;
    }

    Hi,

    it’s fixed in version 12.9.1

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove unnecessary hook and code from version 12.6’ is closed to new replies.