The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Coupon help and cart errors

lablab Member

Hi! I'm trying to add a coupon that takes an amount off a certain product. It's lowering the price from $149.95 to 94.99 for a limited time. I've tried a few settings including selecting the options: Discount by an amount based on the quantity (allunits|1-54), Discount by a percentage based on the quantity (allunits|1-36), and Discount by a percentage based on the price (allunits|149-36). There is no limit on the quantity ordered nor any differences in tiers. It is limited to one category and I've even tried to limit it even further using a product code. I have the date set so I can test it today although once I have it working, it will be effective on a quickly approaching future date. When I test any of these in the cart on the specific product, I receive the following error (and note that it appeared multiple times in the error box):

This coupon has already been added to this order.This coupon is not combinable with any other coupon.This coupon has already been added to this order.This coupon is not combinable with any other coupon.

1. Am I using the coupons correctly for the purpose of the discount?
2. Why am I receiving the error?

Thank you for any help you can give!
Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    edited May 2016
    @lab,

    Sorry to hear you're having troubles with the coupons! Would it be possible for you to whisper to me your store domain? I'd like to take a look at the coupon you've created.

    Without seeing your coupon - it's possible that you've entered multiple variations of the same coupon code in different combinations of upper and lower case (eg 15off, 15OFF, 15Off. The coupon codes are case insensitive, so you just need to specify a given code once. With the multiple codes, each code is matching the code entered, so it's attempting to add the same coupon multiple times when it's not allowed to - hence the errors.
  • lablab Member
    @fc_adam I will whisper the domain to you but I think you are correct about the error I'm receiving: I gave 3 code combinations in case the customer mistypes using uppercase vs lowercase etc.
  • lablab Member
    @fc_adam I've reduced the codes to just one now. No more error, but the discount isn't applying correctly.
  • fc_adamfc_adam FoxyCart Team
    @lab,

    I'm glad the errors are gone. Could you confirm the name of the coupon you're working with please? Sorry, should have asked that previously too.
  • fc_adamfc_adam FoxyCart Team
    @lab,

    Thanks for whispering the name.

    I'm testing that coupon on your store, and it's correctly discounting the product for me. Just to confirm, are you adding a product with the eb_full category set for it?
    Ideally it would apply to the Santa Rosa style under that category, but I'm not sure if the coupon can get that specific?
    If you can set that style to make the product code unique using product option modifiers, you could limit the coupon to just that product code. If you didn't want to change the code, you could also use product optoin modifiers to change the category for just that style to one the coupon applies to. Information on product option modifiers available at the bottom of this page: http://wiki.foxycart.com/static/redirect/add_to_cart
  • lablab Member
    @fc_adam I can't get the coupon to correctly discount for me. It keeps the discount at $0. I am using the eb_full category for this coupon.

    What are the impacts to the cart and any transactions if I add to the option modifier? I'm reading the section about modifiers right now. I would update that in the Website code, right, as opposed to a setting in Foxycart Admin?
  • fc_adamfc_adam FoxyCart Team
    @lab,
    I can't get the coupon to correctly discount for me. It keeps the discount at $0. I am using the eb_full category for this coupon.
    Could you whisper me the link to your page with the add to cart you're using? I'll see if I can replicate what you're seeing.
    What are the impacts to the cart and any transactions if I add to the option modifier? I'm reading the section about modifiers right now. I would update that in the Website code, right, as opposed to a setting in Foxycart Admin?
    The impact is basically that the respective options that the product option modifiers modify will be changed. For example, if you have an option which increases the price by $20, then the product will be added to the cart with the price set from the form increased by $20.

    You would include the option modifiers on the add to cart page, that's right.

    As an example, let's say you had a form and a select dropdown for the style. With product option modifiers to change the category, that would look like this:
    <input type="hidden" name="category" value="normal_category" />
    <select name="style">
    <option value="Red">Red</option>
    <option value="Blue">Blue</option>
    <option value="Santa Rosa{y:new_category}">Santa Rosa</option>
    </select>
    If a customer chose red or blue as a style - the normal_category would be used. If they selected the santa rosa option though, the product would be added to the new_category category.
  • fc_adamfc_adam FoxyCart Team
    @lab,

    Thanks for whispering the add to cart page. Looking at the form you referred to, it's not setting a category specifically within the form - so the product is being added the DEFAULT category. You'll need to add a hidden input which sets the category for that form to eb_full in order for the coupon to correctly apply.
  • lablab Member
    Hi @fc_adam - The main product before choosing the style has a value of eb-c. I tried selecting that from the category drop down on the coupon modification page but it's not an option. If I enter eb-c as the Product Code Restriction and keep the category at default, the coupon discount works, but it takes the discount from both styles of that product instead of that particular one. I tried adding the {y:new_style_category} to that particular style but it resulted in a cart error.
  • lablab Member
    @fc_adam Another update: I added a category to that form as you suggested and set it to eb_full but once added to the cart, I got an error of Cart Validation Error: category_hash_present
  • fc_adamfc_adam FoxyCart Team
    @lab,

    Thanks for the updates.
    The main product before choosing the style has a value of eb-c. I tried selecting that from the category drop down on the coupon modification page but it's not an option.
    The "eb-c" value in the form is the product code, rather than the product category, that's why you couldn't see it there.
    I added a category to that form as you suggested and set it to eb_full but once added to the cart, I got an error of Cart Validation Error: category_hash_present
    The validation errors you're seeing relate to your add to cart form being encrypted - so if you make any changes to it, whether adding new items or modifying existing ones, you'll need to reencrypt the form. How did you handle the form encryption initially?
  • lablab Member
    edited June 2016
    @fc_adam I wasn't the original developer, so I do not immediately know the information on the form encryption.

    As for the code, if that code is applied as an input to just that one product in the storefront and no category is set, is there a way to add additional codes to the styles of that product which are set via select options for that product rather than inputs?
  • fc_adamfc_adam FoxyCart Team
    @lab,

    Are your forms just straight static HTML on your site? Or do you use a CMS or similar to manage your site? If it's the former as a static site, you can manually encrypt your forms using the FoxyCart administration for your store. You can see details for how to approach that here: https://wiki.foxycart.com/v/2.0/hmac_validation#manual_encryption_via_foxycart_administration

    For your form, as it's already encrypted, you'll need to strip it of it's existing hashes before modifying and re-encrypting. For example, your form has an element like this:
    <input type="hidden" name="code||492f0da4aa8b4336e193e0b4418023363565902f7c5e607cb7cb7ff3e0d46611" value="eb-c">
    You'd remove everything after and including the double pipes, so it would look like this:
    <input type="hidden" name="code" value="eb-c">
    For the select value you have, that's in the value of the options instead, so:
    <option value="Santa Rosa||35fd9a13efc23217d4e21f0a85b80c5caa0323b571dfbb3941f444d733ef8b27" class="product-complete-default" data-image="/img/store/product_santarosa_complete.jpg">Santa Rosa</option>
    becomes:
    <option value="Santa Rosa" class="product-complete-default" data-image="/img/store/product_santarosa_complete.jpg">Santa Rosa</option>
    Once you've removed all the hashes - you can then edit the form and paste the entire thing into the Sample Code textarea of the admin to encrypt it for your store.
    As for the code, if that code is applied as an input to just that one product in the storefront and no category is set, is there a way to add additional codes to the styles of that product which are set via select options for that product rather than inputs?
    You can use product option modifiers to change the product code, so that way you could restrict the coupon to just this style. For example:
    <option value="Santa Rosa{c+-santarosa}" class="product-complete-default" data-image="/img/store/product_santarosa_complete.jpg">Santa Rosa</option>
    That will change the code from just "eb-c" to "eb-c-santarosa" if that option is selected.
  • lablab Member
    @fc_adam Thank you! This is making a lot more sense. I had been wondering why the hashes were included and how they were generated. This is a static site form. I stripped the form of its hashes and added that additional code to the select value in question, and re-ran the encoder on the Sample Code page. However, only the last form input -- the only item w/out a <select> option ended up with the new hashes. I did a test of this newly encoded form in the cart and it resulted in an error. Any idea why this happened and what I'm doing wrong?
  • fc_adamfc_adam FoxyCart Team
    @lab,

    Could you whisper me the form you're trying to encode that isn't working? I'll take a look for you.
  • fc_adamfc_adam FoxyCart Team
    @lab,

    Thanks for whispering your form! I believe the issue you're running into is that your form elements are being broken over many lines. If you update it so each input is on it's own single line - I think it should encrypt correctly.

    As an example, instead of this:
    <input
    type="hidden"
    name="code"
    value="eb-b">
    It'd be this:
    <input type="hidden" name="code" value="eb-b">
  • lablab Member
    @fc_adam Thanks! I cleaned up those input areas to make each one on its own line w/out line breaks. It did encrypt correctly. However the encoded html stripped out the <select> code and its options. Which I suppose I could add that back in manually but don't the options need encryption too?
  • fc_adamfc_adam FoxyCart Team
    @lab,

    Could you clarify what you mean by stripping them out? You're right that the option values will need to be encrypted too.
  • lablab Member
    @fc_adam The select tag and its option values were gone from the final code when I ran the HTML encrypt tool. I tried a few times to make sure it wasn't a copy and paste mistake.
  • fc_adamfc_adam FoxyCart Team
    @lab,

    Could you whisper me the code you're trying to encrypt? I just did a quick test and it worked fine for me.
  • fc_adamfc_adam FoxyCart Team
    @lab,

    Thanks for whispering the form. I was able to replicate what you were describing there - the select element in the first form is disappearing. The select in the second form isn't though.

    This appears to be down to the option elements in the first form being broken over multiple lines. If I edited them into single lines each, it correctly encoded.

    That said - it shouldn't be completely dropping the code like that, and not supporting it over multiple lines isn't helpful either. I'll create a ticket on our side to look into making improvements there.
Sign In or Register to comment.