Support » Theme: Storefront » Coupon code discount on on product page

  • Resolved pawelpal2

    (@pawelpal2)


    Hi Guys,

    I am constantly looking for a solution to a basic problem.
    The use case is.

    I want my clients to come to a website through a link that will include a coupon code like: http://www.domain.com/?add-to-cart=234&code=25OFF
    Which will result in add a specific product to a cart and apply the sitewide coupon code for 25% off the regular price.

    The mechanism works – it adds the product and applies the reduction – but I can’t see the reduced price in the store – only on the checkout page.

    The effect I would love to get:
    1. Client comes through a customized link with a coupon code and see the reduced price on products selected in the coupon code and are visible across the shop without the product added to the cart.

    The issues i had come across:
    1. You can’t apply a coupon code without a product in the cart (Resolved by adding a Coupon Code product that is being added through the customized link)
    I have used this piece of code: https://stackoverflow.com/questions/48220205/get-a-coupon-code-via-url-and-apply-it-in-woocommerce-checkout-page

    2. After applying a coupon to a fake product – the shop prices are still regular and only reduced in the checkout process.
    I have tried this piece of code: https://reigelgallarde.me/programming/show-discounted-price-product-page-using-coupons/

    It shows the reduced prices on the product pages but i get the error in the admin panel in products under price:
    Fatal error: Uncaught Error: Call to a member function has_discount()

Viewing 2 replies - 1 through 2 (of 2 total)
  • Job

    (@jobthomas)

    Automattic Happiness Engineer

    Hey @pawelpal2 – thanks for the question. A few remarks.

    First of all, this isn’t a Storefront related question, but one related to WooCommerce and this is not the right forum for that.

    Second, this seems like a very custom option to build. I can leave this thread open for a few extra days to see if someone is able to help. Alternatively, I’d suggest contacting a developer here, on our WooCommerce Customizations Page.

    Theme Author Automattic

    (@automattic)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.