We offer free samples at $0 cost. We want to limit the quantity a customer can purchase of each sample to only one. Is there a way to prevent someone from ordering more than one of a particular product?
Thanks
<script>
<!-- Aug 14, 2013 This checks for quantity > 1, which is highly unlikely for downloads. -->
var quantity_check = true;
if (quantity_check && button == "8") {
var nQuantityN = 0;
for (var i=0; i < number_products; i++)
{
if ( ss_quantity[i] > 1)
nQuantityN += 1;
}
if ( nQuantityN > 0 )
return (confirm ("At least one item in your cart has the quantity set to more than one. If you only meant to order one of each item, please press Cancel now and correct your order, else press OK to proceed to the checkout."));
}
</script>
if ( ss_sku[i] == "FREE_SAMPLE_SKU" && ss_quantity[i] > 1)
nQuantityN += 1;
// Don't let customer order more that quantity one for SKU_123
var quantity_check = true;
if (quantity_check && button == "8") {
var nQuantityN = 0;
for (var i=0; i < number_products; i++)
{
if ( ss_sku[i] == "SKU_123" && ss_quantity[i] > 1) {
ss_quantity[i] = 1;
nQuantityN += 1;
}
}
if ( nQuantityN > 0 ) {
alert ("Sorry, only one free sample per customer. Quantity has been changed to one.");
// or perhaps...
alert ("Sorry, only one free sample per customer. Please set the quantity to 1 before proceeding to Checkout, thank you.");
return (false);
}
}
// Don't let customer order more that quantity one of the following SKUs
var my_skus = ["SKU_X", "SKU_Y", "SKU_Z"];
var quantity_check = true;
// Perform the check
if (quantity_check && button == "8") {
var nQuantityN = 0;
for (var i=0; i < number_products; i++) {
for (var j = 0; j < my_skus.length; j++) {
if ( ss_sku[i] == my_skus[j] && ss_quantity[i] > 1) {
ss_quantity[i] = 1;
nQuantityN += 1;
}
}
}
if ( nQuantityN > 0 ) {
alert ("Sorry, only one free sample per customer. Quantity has been changed to one.");
// or perhaps...
alert ("Sorry, only one free sample per customer. Please set the quantity to 1 before proceeding to Checkout, thank you.");
return (false);
}
}
Users browsing this forum: No registered users and 57 guests