Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
    Posts
  • #811612

    Hi Guys,

    Ok I added a hook to show a button on the single product page

    add_action(‘woocommerce_after_add_to_cart_button’,’cmk_additional_button’);
    function cmk_additional_button() {
    echo ‘<button type=”submit” class=”button alt”>test</button>’;
    }

    This works and is shown on all products now.

    How can I restrict this so it only shows on single product pages that are within certain categories, for example “Commercial Gym Equipment” only?

    Thank you in advance.

    #811774

    Hey Gekko101,

    You need a conditional statement that would check for category id or single product template and show it then.

    Best regards,
    Victoria

    #811788

    Thanks, I got it working here (link supplied)

    How can I pad the space between the new button and the Add to Cart button?

    #811796

    The extra button seems to have the class – button.button.alt (I could be wrong)

    How can I pad this new button or in fact pad the existing ‘Add to cart’ button to make a space between the 2 buttons?

    #811967

    Hi,

    Please try the following in Quick CSS under Enfold->General Styling:

    .single_add_to_cart_button {
        margin-right: 10px;
    }

    Best regards,
    Rikard

    #812054

    Thanks, however this code doesnt work for me and doesnt change this?

    .single_add_to_cart_button {
    margin-right: 10px;
    }

    #812255

    Hi Gekko101,

    Here is the code you can put in Enfold > General Styling > Quick Css,  if it does not work, put into themes/enfold/css/custom.css

    
    .single_add_to_cart_button {
        margin-right: 10px !important;
    }
    

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #812461

    Thank you, this works!

    However when I click the new ‘Commercial Finance’ button, instead of linking out to the relevant page it adds the item to the cart instead?

    The full code I’m using is –

    add_action(‘woocommerce_after_add_to_cart_button’, ‘cmk_additional_button’);
    function cmk_additional_button() {

    if ( is_product() && has_term( ‘Commercial Gym Equipment’, ‘product_cat’ ) ) {
    echo ‘<button type=”submit” class=”button alt”>Commercial Finance Available</button>’;
    }
    }
    Why is this new button adding products to the cart, its only meant to be a button that links to a page?

    • This reply was modified 7 years, 5 months ago by Gekko101.
    #812473

    Hi,
    try removing [type=”submit”] from your function

    Best regards,
    Mike

    #812475

    Thanks, I tried this but if I remove button type=”submit” it removes the entire button and just leaves behind the text?

    #812483

    Hi,
    I meant like this:

    <button class=”button alt”>Commercial Finance Available</button>

    Best regards,
    Mike

    #812489

    Thanks for the reply mike, however it changed the style of the button, but it still adds the item to the cart and doent link out to the nominated URL

    #812490

    Also I note when I post the code here, the forum strips some of the details out

    #812492

    Hi,
    Oh, that link makes more sense :) I’ll have to do some more research.

    Best regards,
    Mike

    #812547

    Thanks Mike, let me know what you think, I have a client breathing down my neck on this one ;(

    #812945

    Hi Gekko101,

    You don’t have a closing tag to the link in your code. Try adding it. Also, you don’t need the button element, you can have just the link and style it as the button.

    View post on imgur.com

    Best regards,
    Victoria

    #812955

    Thank you so much for your reply, I have added the closing tag however it makes no difference.

    I keep going round and round in circles with this one… :(

    #813058

    Hi Gekko101,

    You could try these attributes

    View post on imgur.com


    but the button is in the form, so even that might not work, you have to find another action, that would render the button outside of the form.

    Best regards,
    Victoria

    #813081

    Thank you, this has finally worked. Thank you very much :)

    The button is misaligned on mobile devices however..

    • This reply was modified 7 years, 5 months ago by Gekko101. Reason: Update
    #813111

    Hi,

    We’re glad that the team was able to help you. We’ll close this thread now, but if you have any other questions or issues, feel free to post them here on the forum and we will do our best to help.

    Thank you for using Enfold.

    Cheers!
    Sarah

Viewing 20 posts - 1 through 20 (of 20 total)
  • The topic ‘Show button for nominated category only?’ is closed to new replies.