Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #296541

    Hi. I recently bought Enfold and I am using it in combination with Woocommerce and their extension called Product Add-ons.
    The problem is in the layout, on product pages where the Product Add-ons are used and related products are displayed at the bottom.

    Product without add-ons – layout is ok:
    https://www.alandra.be/product/soekris-net6501-30-board-case-only/

    Product with add-ons – add to cart button in related products (bottom) is shown twice:
    https://www.alandra.be/product/soekris-net6501-50-complete-set/
    Once in blue, once in the standard enfold style. The 2 buttons also do different things. The blue one is the correct one.

    What could be causing this?

    Thanks in advance.

    #297355

    Hi denisdetaeye!

    Probably the ” Product Add-ons” extension registers a new product type which is different from the default WooCommerce product types and thus it breaks our related products section. I recommend to contact the plugin author – maybe he can provide some tips how to rewrite the default “Add to cart” button code of our theme so that it works with his extension (it can be found in wp-content/themes/enfold/config-woocommerce/config.php and it’s wrapped into a function called avia_add_cart_button()). If he can’t help you you can either remove the related products section with php code (insert it into the functions.php file of the child theme or the Enfold parent theme):

    
    
    add_action('after_setup_theme','avia_remove_related_products', 10);
    function avia_remove_related_products()
    {
            remove_action( 'woocommerce_after_single_product_summary', 'avia_woocommerce_output_related_products', 20);
    }
    

    or you can try to hire a freelancer/coder who can dig into the extension code and customize the extension and/or theme files for you.

    Best regards,
    Peter

    #298185

    Hi Peter,

    I have contacted Woothemes and they are looking into it.
    Thanks for the support.

    Kind regards,

    Denis.

    #299103

    Hi!

    Great, I’ll leave the thread open in case additional help is required.

    Cheers!
    Peter

    #299116

    Peter,

    I resolved the problem myself, Woothemes wasn’t very hulpful.
    This needs to be added to QuickCSS to hide the blue (duplicate) order buttons in related products:

    
    .related ul.products a.add_to_cart_button { display:none; } 
    .related ul.products .avia_cart_buttons a.add_to_cart_button { display:block; }
    

    And this is the modified wp-content/plugins/woocommerce/templates/loop/add-to-cart.php:

    
    <?php 
    /** 
    * Loop Add to Cart 
    * 
    * @author WooThemes 
    * @package WooCommerce/Templates 
    * @version 2.1.0 
    */
    
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    
    global $product;
    
    // ## DENIS - 31/07/2014 
    $theurl = ($product->product_type == 'addons' ? $theurl = get_permalink( $product->id ) : $product->add_to_cart_url() );
    
    echo apply_filters( 'woocommerce_loop_add_to_cart_link', 
    sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="button %s product_type_%s">%s</a>', 
    // ## DENIS - 31/07/2014 
    //esc_url( $product->add_to_cart_url() ), ## ORIGINAL 
    esc_url( $theurl ),
    esc_attr( $product->id ), 
    esc_attr( $product->get_sku() ), 
    $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', 
    esc_attr( $product->product_type ), 
    esc_html( $product->add_to_cart_text() ) 
    ), 
    $product );
    

    As you can see the Woothemes Products Add-on doesn’t take into account the “addons” product type when constructing the add to cart/view product button.
    That’s all, and produces the desired and correct result.

    Denis.

    #299122

    Hey!

    Glad you found a solution :)

    Regards,
    Peter

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Double buttons in related products when using Woo's Product Add-ons’ is closed to new replies.