I know this thread is kind of old, but it's the most relevant to my question, so I'm going to give it a shot:
I managed to prevent logged in users from adding an item to their cart if they've already purchased the maximum, but if they add the items when they're not signed in and then log in to complete their purchase, they beat the system.
So my question is: what file would I need to modify to pull items out of the cart when they've already made it to the checkout page?
I'm using Fast and Easy Checkout if that makes a difference. If someone is on the checkout page when they log in, it brings them right back to where they left off.
For anyone who needs to just block people from adding an already maxed out item to their cart, this is what I did...
Since all my products have a download attribute and you have to go through the product info page, I put the booby trap there.
In the pages/product_info/header_php.php file, I added this toward the top:
Code:
$query_max = "select SUM(op.products_quantity) as total_qty
from " . TABLE_ORDERS . " o, " .
TABLE_ORDERS_PRODUCTS . " op
where o.orders_id = op.orders_id
and o.customers_id = '" . $_SESSION['customer_id'] . "'
and op.products_id = '" . (int)$_GET['products_id'] . "'";
$max = $db->Execute($query_max);
$quantity_purchased = $max->fields['total_qty'];
And in then on the tpl_products_info_display.php page, in the add to cart section, right after
Code:
<?php
if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') {
// do nothing
} else {
?>
I added this:
Code:
<?php if (($products_quantity_order_max != '0') && ($products_quantity_order_max <= $quantity_purchased) && ($products_quantity != '0')) {
echo zen_image_button(BUTTON_IMAGE_MAXED_OUT, BUTTON_MAXED_OUT_ALT) .'<div class="sorryText">You\'ve already bought the maximum allowed for this deal, but don\'t worry, there are plenty more to enjoy!</div>';
} else {
and don't forget to add an extra one of these bad boys before eof Add to Cart Box
to close the if else statement.
I'm going to tweak the shopping cart class to update the quantity if someone's trying to make a new purchase where the quantity is within the per session max, but would put them over the per cart max - I'll post that code when I finish.
I'm using v1.3.8a btw