![]() |
flexi cart - A comprehensive shopping cart library for CodeIgniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: flexi cart - A comprehensive shopping cart library for CodeIgniter (/showthread.php?tid=50013) |
flexi cart - A comprehensive shopping cart library for CodeIgniter - El Forum - 03-12-2013 [eluser]khangwei[/eluser] Hey Rob, Thanks for your input. My concern around your suggestion is that I am summing up the voucher values and putting them into the cart session. If the user does not check out, the total discount value is stored in the session. Now imagine you have another user who puts in the same voucher code. If the voucher can only be used once, we have the effect of the same voucher being applied twice and both gets the discount. A workaround I thought to add on to your suggestion is to concatenate the voucher codes in the description of the manual voucher. So, I can run a function to check if the voucher is already redeemed. What do you think of this? Or anyone? With regards to normal discounts (not voucher based), what do you mean by I should use set manual discount instead of using the database table? Why so? In any case, since summary discount is not stackable, I should also be concatenating normal discounts with my custom vouchers in a manual discount right? Any advice anyone? Appreciate it. Thanks all! flexi cart - A comprehensive shopping cart library for CodeIgniter - El Forum - 03-13-2013 [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. flexi cart - A comprehensive shopping cart library for CodeIgniter - El Forum - 03-25-2013 [eluser]koichirose[/eluser] Hi haseydesign, I ran into an issue while testing weird product names for other reasons. It looks like if you add something to the cart with a backslash in its name ('\'), the flexi_cart->insert_items() function will return true, but the item won't be added to the cart. Here's an example of what I'm trying to add to the cart: Code: array I also tried with other properties (ex. store->store, or brand): a backslash breaks it. I tried looking around, it looks like everything's fine up to the call to the function set_item_data() in flexi_cart_model.php:427 . Probably related: I get logged out of my normal user session if I try and add an item like that to the cart. What could it be? Thank you ![]() flexi cart - A comprehensive shopping cart library for CodeIgniter - El Forum - 04-08-2013 [eluser]haseydesign[/eluser] Hey koichirose, Sorry for the delayed response, I've been away for a bit. I can only guess that the issue is being caused something within Codeigniters core upon page refresh. If you add the following code just after you call the insert_items() function, it shows that the item has been set to the current session data (Which is managed by CI), however, upon page refresh, the session is completely wiped, hence why you're also being logged out. Code: $this->flexi_cart->insert_items($item_data); I can only suggest you put in some kind of custom filter to strip any values with a backslash being added to the cart. Ideally, when I can get around to it, I will try and include a filter to strip them out before being saved to the session data. flexi cart - A comprehensive shopping cart library for CodeIgniter - El Forum - 04-09-2013 [eluser]Matthew Diggins[/eluser] Hi, I've been incorporating Flexi cart into Fuel CMS. On the way I've found a few method calls from the admin_library controller that don't exist eg "get_db_table_data_array()", "get_db_config_row_array()" and "get_db_table_data_row_array()". While these are not too hard to re-imagine, I thought I'd better check to see if these were intentionally absent? flexi cart - A comprehensive shopping cart library for CodeIgniter - El Forum - 04-09-2013 [eluser]od3n[/eluser] hi everyone, is it possible to create a row for same item instead of update the quantity? flexi cart - A comprehensive shopping cart library for CodeIgniter - El Forum - 04-10-2013 [eluser]haseydesign[/eluser] @od3n Checkout item example #117 on http://haseydesign.com/flexi-cart/lite_library/item_link_examples When you're creating the array of item data to insert to the cart, you need to include the array key/value of 'unique' => true. See this around line 235 of the included demo_cart_model.php file. @Matthew Diggins The 'x_array()', 'x_row_array()', 'x_row()' named versions of the library functions do not exist as actual code for any of the libraries functions. Instead they use the PHP __call() method to create these alias function names that all utilise the 'x_query()' version of the function (Which is defined as actual code), and then apply CI's Active Records methods (eg $x->result_array()) to the 'x_query()' function. For example, you will not find a function named 'get_db_shipping_array()' within the library code, however, there is a 'get_db_shipping_query()' function, which if you call 'get_db_shipping_array()', the __call() method with automatically create the alias for the function and apply CI's AR method to the function, essentially calling 'get_db_shipping_query()->result_array()'. You can find the __call() method doing this at around line 38 of the Flexi_cart_lite.php library file. You can also read a little more on this at http://haseydesign.com/flexi-cart/user_guide/query_sql_results I hope that helps you with your question. flexi cart - A comprehensive shopping cart library for CodeIgniter - El Forum - 04-10-2013 [eluser]od3n[/eluser] thanks Rob, it works! flexi cart - A comprehensive shopping cart library for CodeIgniter - El Forum - 04-19-2013 [eluser]stu_chilli[/eluser] Hi, I'm looking at implementing your code (which is ace by the way) and I'm just having a slight issue and wonder if you can help. I want to make the carts more persistent in that I want it if someone adds something to their cart, leaves the site and comes back 2 weeks later the item is still in their cart. I've searched but can't see something. I'm aware of the of the cart db save feature but I'm wondering if there is an easy way to get this action working? If not and thats what the save function if for has anyone implemented it from a logic point of view i.e. at what point do you save, how do you link the saved basket to the member if they haven't yet logged in so you don't have a customer id? Any help would be appreciated! flexi cart - A comprehensive shopping cart library for CodeIgniter - El Forum - 04-21-2013 [eluser]haseydesign[/eluser] @stu_chilli You seem to have identified what you need to do and the potential pitfalls you may come across. What I would suggest, is that whenever anything is changed within the cart, whether that be item quantities, shipping location, discounts etc - then as soon as the cart has been updated, fire the save_cart_data() function to save the entire cart details to the database. You haven't got to worry about deleting the old cart data and inserting a new row of data as the function will detect it was originally loaded from the database and will overwrite the existing data upon being resaved. The problem you then highlighted with associating cart data with non logged in users should be easy enough to overcome by using a regular cookie set via CI that includes a unique random identifying token/number. You need to define this cookie yourself and then pass the cookie value to the function via the 'sql_update' parameter. Regarding then ensuring this data is available as soon as the user revisits the site, simply have a quick check that is called on every page that checks if the user has a save cart cookie, but also has nothing setup in their cart, in which case, you can load the data to their cart. If you go ahead using this cookie token method, then you should probably do it for all users, regardless of whether they are logged in, this will prevent complications with detecting logged in users and what to do with their cart data if they login/logout midway through their cart. However, note, that when you want to save cart data for other purposes - like associating the data with a confirmed order, this is when you should still use the users id param. HTH |