BLACK FRIDAY BIGGEST SALE EVER!! Use coupon code BF33 to get 33% discount on all our products. Enjoy!

Replace add to cart on shop page with link to product page

Home Forums Ample Free Replace add to cart on shop page with link to product page

This topic contains 7 replies, has 5 voices, and was last updated by  Nima 3 days, 15 hours ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1290819

    cherylwood
    Participant

    Hoping someone can help! I want to replace the Add to cart button on my WooCommerce shop page with a normal button that links to the single product page for each product. I have found that people visiting the site dont seem to realise they can click on the product and get a description and further photos so I would like them to be forced into doing this. I would like to keep the add to cart button on each individual product page.

    I found some info online which has helped a little – If I post the following into the theme function code within the editor for the theme, then I can remove the add to cart buttons:

    /*STEP 1 – REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */

    function remove_loop_button(){
    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 );
    }
    add_action(‘init’,’remove_loop_button’);

    but then the info I found said to add the following to replace the button with “read more” button which links to individual product pages:

    /*STEP 2 -ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */

    add_action(‘woocommerce_after_shop_loop_item’,’replace_add_to_cart’);
    function replace_add_to_cart() {
    global $product;
    $link = $product->get_permalink();
    echo do_shortcode(‘<br>[button link=”‘ . esc_attr($link) . ‘”]Read more[/button]’);
    }

    this is where I have the problem. when i do this, instead of a read now button, i get the following displayed where the button would be:

    [button link=”http://alonesoap.com/product/wake-up-soap/”]Read more[/button]

    Can anyone suggest what is wrong? I am using the Ample free theme if that helps.

    #1290896

    Nima
    Moderator

    Hello @cherlywood,

    Please, go to the options WooCommerce->Settings->Product. Now under Product browse the option “Display” you can find the label “Add to cart behaviour” where remove the both tick and save the changes check. Hope, after removing this tick the Add to cart button will redirect to the particular product page.

    And post us back if your problem still persists.

    Regards!
    ThemeGrill Support Team

    #1291012

    cherylwood
    Participant

    Hi,

    Thanks for your reply, I have tried this but unfortunately it has not solved my problem!

    I have two tick boxes at the Add to cart behaviour:

    Redirect to the cart page after successful addition
    Enable AJAX add to cart buttons on archives

    When I untick the “Enable AJAX add to cart buttons on archives”, and save changes, the result when I click add to cart on the main shop page is to stay on this page but a new section at top (above products, but below header area) that says ” “Wake Up Soap!” has been added to your cart” and with a bottom appearing on right hand side for “view cart”

    If I have the “Enable AJAX add to cart buttons on archives” ticked and save changes, and save changes, the result when I click add to cart on the main shop page is to stay on this page but a link (“View cart”) appears right next to the add to cart button which I clicked.

    Unfortunately none of these options open the product info page for item. Ideally, I just to get rid of add to cart option on the product page altogether and just have it link to the individual product pages where they can choose add to cart there if they wish.

    many thanks for your help

    #1291106

    Nima
    Moderator

    Hello @cherylwood,

    If this doesn’t work for you then your theme code needs to be customized. So, please contact to our customization team for your query if you really want to fulfill your query. Hope, you understand.

    Regards!
    ThemeGrill Support Team

    #1315248

    arvindlogicworld
    Participant

    Hello @cherylwood,

    Use this code

    add_action( ‘woocommerce_after_shop_loop_item’, ‘mycode_remove_add_to_cart_buttons’, 1 );
    function mycode_remove_add_to_cart_buttons() {
    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’ );
    }
    /**
    * Adds a “More Details” button on list of products (ex. category pages).
    */
    add_action( ‘woocommerce_after_shop_loop_item’, ‘mycode_add_more_info_buttons’, 1 );
    function mycode_add_more_info_buttons() {
    add_action( ‘woocommerce_after_shop_loop_item’, ‘mycode_more_info_button’ );
    }
    function mycode_more_info_button() {
    global $product;
    echo ‘id ) . ‘” class=”button add_to_cart_button product_type_external”>More Details‘;
    }

    #1332554

    alexanderbiscajin
    Participant

    First step you can do is to remove add to cart button using this code.

    function WpBlog() {
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');
    return WooCommerce::instance();
    }

    Reference: https://www.wpblog.com/add-to-cart-button-in-woocommerce-store/

    #1333670

    Abour1986
    Participant

    hey im also facing the same issue with my site 🙁

    #1333889

    Nima
    Moderator

    Hi Abour1986,

    Could you please mention us about your issue in detail and also provide us your site URL.
    We will have a deep look on it and provide you a solution.

    Regards!
    ThemeGrill Support Team

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

You must be logged in to reply to this topic.