jeffharrell / minicart

The minicart is a great way to improve your PayPal shopping cart integration.
MIT License
500 stars 209 forks source link

Using Discount_num to limit discounts per item #286

Open legenderrys opened 8 years ago

legenderrys commented 8 years ago

@jeffharrell Currently when this option is used the item will display a negative value. To test this copy/paste the code below into the demo page.

<fieldset>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<input type="hidden" name="business" value="example@minicartjs.com">
<input type="hidden" name="item_name" value="Unicorn">
<input type="hidden" name="amount" value="2.00">
<input type="hidden" name="discount_amount" value="0">
<input type="hidden" name="discount_amount2" value="1.00">
<input type="hidden" name="discount_num" value="3">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="http://www.minicartjs.com/?success">
<input type="hidden" name="cancel_return" value="http://www.minicartjs.com/?cancel">
<strong>Unicorn</strong>
<ul>
<li>Price $2.00</li>
<li>Discounted $1.00</li>
</ul>
<input type="submit" name="submit" value="Add to cart" class="button">
</fieldset>

The above code sets a limits the discount_amount2 value to only 3 items based on the discount_num option. However, you will see the following: image

I don't believe this is a feature with this plugin, but would be great to know where to correct this issue.

I would guess this line here may be the culprit...not sure. but would like to think if a conditional would be added that verifies if the discount_num is greater than 0 to use observe the current quantity and apply the discount if less than or equal to discount_num.