Turn off cart for some products

Hi,

The client has a number of products where the shipping is complex and therefore wants to be able to show the product but not allow it to be purchased via the cart... they just want to direct them to calling or use email to order for these products. Is there any way i can do this for individual products or is there a way round this...

Your suggestions are much appreciated.

:wink:

  • Predrag Dubajic
    • Support

    Hey Studio3creative,

    Hope you're doing well today :slight_smile:

    Unfortunately something like this is not possible with MarketPress but I might have a possible solution for you.
    With below CSS you will hide add to cart button and replace it with the email and phone text.

    #mp-single-product-9 .mp_button-addcart, /*For single page*/
    #mp-buy-product-9-form button /*For shop page*/ {
        display: none;
    }
    
    #mp-single-product-9 .mp_product_options_atts:after, /*For single page*/
    #mp-buy-product-9-form:after /*For shop page*/ {
        content: "Purchase over phone or email \A Phone: PHONE_PLACEHOLDER \A Email: EMAIL_PLACEHOLDER ";
        white-space: pre;
    }

    What you need to do is replace "9" with the ID of your desired product and add your phone and email in placeholders.

    If your theme doesn't have custom CSS field, then you may wish to use a child theme or a plugin like this one for this additional CSS. That way you're protected when you come to upgrade.

    Hope this helps :slight_smile:

    Best regards,
    Predrag

  • Studio3creative
    • The Bug Hunter

    Thanks for this Pedrag,

    I think this is a good solution however i have added the code in the css editor for one product to test (ID 1400) but it isn't effecting the site (i used !important also) but no joy?

    I have enabled access to the back of the site so if you could take a look that would be great.

    :slight_smile:

    :slight_smile:

  • Adam Czajczyk
    • Support Gorilla

    Hello Studio3creative!

    I'm sorry we weren't able to respond to you faster but we experienced a temporary "spike" in a number of questions and since you posted (https://premium.wpmudev.org/forums/topic/turn-off-cart-for-some-products#post-1160966) without waiting for a staff response you thread got automatically moved down the queue. Just to let you know, the classic "thread bumping" here works quite opposite to most of the forums. I think it's good to know that :wink:

    As for your question.

    For "single product pages" this code should work:

    .product_category-carrabinas .mp_button-addcart, /*For single page*/
    .product_category-carrabinas button /*For shop page*/ {
        display: none;
    }
    
    .product_category-carrabinas .mp_product_callout:after {
        content: "Purchase over phone or email \A Phone: PHONE_PLACEHOLDER \A Email: EMAIL_PLACEHOLDER ";
        white-space: pre;
    }

    As you can see there's a specific class name used: "product_category-carrabinas", it's created out of the category name.

    There'd be however no similar way to do the same on category listing page because the category name doesn't get added anywhere there. The solution would be to create an additional custom page template for such category archive in order to make it use some unique class there as well.

    Kind regards,
    Adam

  • Studio3creative
    • The Bug Hunter

    Hi Adam,

    Thanks for your last input... one last question...

    I would like to drop the following text undernieth the Product name and price on individual product pages (i think you are calling them single pages) within the category 'Manakins' only.

    Due to the shipping requirements for a product of this size and weight we are unable to take online payments. To order, please call 0151 708 9785 to speak to one of our sales co-ordinators or email info@completetrainingsolutions.co.uk.

    I do not want the info to show on the shop page though as your code did before.

    many thanks In advance for your help.

    :slight_smile:

  • Dimitris
    • Support Star

    Hey there Studio3creative,

    hope you're doing good and don't mind chiming in! :slight_smile:

    I attach here a .zip file which contains a functions.php file with a single function.
    This is actually a duplicated function from /wp-content/plugins/marketpress/includes/common/template-functions.php#2336 with the following addition at around line#197 (of the attached file)

    $taxonomies = get_the_terms( $product_id, 'product_category' );
        foreach ( $taxonomies as $taxonomy ) {
          if ( 'Manakins' == $taxonomy->name ) {
            $return .= 'Due to the shipping requirements for a product of this size and weight we are unable to take online payments. To order, please call 0151 708 9785 to speak to one of our sales co-ordinators or email <a href="mailto:info@completetrainingsolutions.co.uk">info@completetrainingsolutions.co.uk</a>.';
          }
        }

    You can use the content of functions.php file straight inside the functions.php file of your current child-theme, just keep in mind to be inside PHP tags like

    <?php
    // function code
    ?>

    Hope that helps, I look forward for your results on this! :slight_smile:
    Warm regards,
    Dimitris

  • Studio3creative
    • The Bug Hunter

    Hi Dimitris,

    Thanks for the help... however I have tried dropping the code into both the Child Functions file and also the Main Functions file but no joy? Its not appearing.?

    I have enabled access to the back of the site so if you could take a look for me that would be great.

    :slight_smile:

  • Adam Czajczyk
    • Support Gorilla

    Hello Studio3creative!

    I checked the site and I can see that the category is actually called "Training Manakins" while Dimitris used just "Manakins" in his code - as you named it in your previous post :slight_smile:

    Please replace this line

    if ( 'Manakins' == $taxonomy->name ) {

    in Dimitris code with this one

    if ( 'Training Manakins' == $taxonomy->name ) {

    I think this should solve the problem. Let me know if it worked for you, please!

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.