Welcome Guest, Not a member yet? Register   Sign In
flexi cart - A comprehensive shopping cart library for CodeIgniter

[eluser]haseydesign[/eluser]
@khangwei

The issue you mention is a very valid problem that you need to address when implementing your solution.
The problem isn't only limited to if a user adds the voucher and doesn't then use it by placing an order, the problem would still exist if 2+ users were using the same voucher at the same time.

Essentially you are going to have to build your own more simplified set of discount methods that are then going to work with the flexi-cart libraries own discount methods.

To work around the initial problem you mention, you will need to implement regular voucher status checks whenever the cart is updated or an attempt to save the cart as an order is made.
The checks will need to validate that all applied vouchers are still valid, if not, then the manually set discount will need to be updated or destroyed accordingly.

When the order is confirmed and saved, you will then need to update your custom vouchers so that if they can only be used once, that they are no longer available.

Regarding why (For your example) you should use the ‘set_discount()’ function to manually set discounts rather than using the discount database tables is that your own custom voucher tables are already doing many of the jobs of the flexi-cart library discount tables (Storing codes, discount values and usage limits).
All the manually set discount needs to know, is the type of discount to apply, the value, and a name - it will simplify the process for you rather than trying to manage another set of tables.


Messages In This Thread
flexi cart - A comprehensive shopping cart library for CodeIgniter - by El Forum - 03-13-2013, 02:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB