Support » Plugin: WooCommerce » Filter for "add_to_cart" shortcode?

  • Would it be possible to have a filter for how the “add_to_cart” shortcode?

    I am changing how that output looks as you can see here on this page: http://www.oxpal.com/guardians-to-the-wall.html

    In this case I add similar categories, and change the button depending on the product type/availability.
    But right now I have to hard-code that into the class-wc-shortcodes.php – and with every update I have to add my code again.

    It seems to me that many people would want to have the look personalized for their shop. Would it be possible to add a hook/filter there to make that easier?

    https://wordpress.org/plugins/woocommerce/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Thomas Schmall

    (@oxpal)

    Is there another place where I can suggest those code changes?

    Hi. Are you using a child theme?

    I really like how you did your cart page. I’d really like to see how you coded that.

    Thread Starter Thomas Schmall

    (@oxpal)

    The cart page where you check out? I didn’t do much with those default wooCommerce pages, except lots of little CSS tweaks. Glad it paid off, thanks 🙂 Other than that my page uses my own theme.

    If you mean the add-to-cart buttons on the blog posts, then I can post the code.

    No I was talking about your css on your checkout. Looks really nice. I guess I’ll have to experiment.

    The reason I asked about the child theme though was because if you are using a child theme you shouldn’t have to add the code back in after every update, (unless, of course, woocommerce breaks their own code. Which they do sometimes.)

    Thread Starter Thomas Schmall

    (@oxpal)

    I achieved enlightenment! Thus allowing me to use filters 😀

    I now first filter the price display, and then the cart button – each time attaching before or after my extra html. But I have to make sure in the code that it only affects the shortcode on the blog – not the woocommerce pages, and oddly also so it doesn’t affect the admin page.

    Thanks for the hint to the child-themes JukeBoxWhiz. It got me on the right track, even though it’s a different workaround in the end. Because Wocoomerce doesn’t offer templates for the shortcodes either.

    It’s a bit hacky – so would love if the admins of WooCommerce would add a clean way to change the shortcode look. I’m not the only one asking for it.
    But I’m happy now I don’t have to edit the code on every update 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Filter for "add_to_cart" shortcode?’ is closed to new replies.