Tom Muck's blog
Removing items from cart that are sold (ColdFusion)
Saturday, October 03, 2009 10:22:04 AM
One of the frequent questions I get doing support for Cartweaver is "How do I make sure that all the items in a customer's cart are still available?" What happens is that a customer will place an item in the cart, and then leave the site. Another customer comes along and buys the product. The first customer comes back and tries to purchase the item, but cannot. Unfortunately, the customer doesn't find out until the order information is entered.
The following modification for the ColdFusion version will remove items from the cart that are no longer available, and show the customer a message that an item has been removed from the cart because it is no longer available.
Now, in CWIncFunctions.cfm, add the following section of code at line 399, right after this line:
Add the following code:
SELECT c.cart_sku_ID, c.cart_sku_qty, s.SKU_Stock, c.cart_Line_ID
FROM tbl_cart c
INNER JOIN tbl_skus s
ON c.cart_sku_ID = s.SKU_ID
WHERE c.cart_custcart_ID =
AND s.SKU_Stock < c.cart_sku_qty
DELETE FROM tbl_cart
WHERE cart_Line_ID =
UPDATE tbl_cart SET cart_sku_qty =
WHERE cart_Line_ID =
Now, when a user comes back to view his cart, any items that are no longer available are removed from the cart and a message is displayed to the customer, and items that have smaller quantities available than were available at the time of the cart creation have their values adjusted. This only affects carts where Allow Backorders is unchecked in the Cartweaver admin.
Update: 10/4/2009 Thanks to Alex in the CW support newsgroup for pointing out that the method does not consider quantities in the cart greater than available quantities. It was written for one situation, but I have now adjusted the code to work with all situations where a quantity is no longer available for a given item
Category tags: Cartweaver, ColdFusion, FAQ
Posted by Tom Muck
Add comment
|
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Before posting comments or trackbacks, please read the posting policy.
Blog RSS feed