flexi cart - A comprehensive shopping cart library for CodeIgniter |
[eluser]haseydesign[/eluser]
Hey Rei, I can give you a generic example of how you can get the price from the database, but this is using an example database schema that will not necessarily fit your requirements, so you will have to adjust it to your needs. If your not too familiar with ecommerce database schemas, spend a little time researching on Google, as different table structures can have many advantages and disadvantages to each design structure. Remember, all you essentially need to do is create an array of the products data, and then add that data to the cart via the 'insert_items()' function. How you get that product data is completely up to you. Code: // Get the id of the product option from POST data.
[eluser]rei[/eluser]
Thank you very much sir for your very informative sample ![]() ![]()
[eluser]PoetaWD[/eluser]
EDIT: Looks like this is a CHROME BUG.... :/ ... Have you seing this before ? Hey man... There is something wrong when using your library with AJAX... :/ Let me show you: To manually add a product in the cart: http://clubemagic.com/cart/addCardToCart/116 (116 is the product ID) To add a product with AJAX: http://www.clubemagic.com/site/card/avr/79 (Click on the orange button) To see the cart array: http://clubemagic.com/cart The problem: When I add the product manually it works... When I add the product using AJAX it doesnt work... The system returns me a success message, but the product doesnt show in the cart list... :/ Can you help me ?
[eluser]haseydesign[/eluser]
Hey PoetaWD, It looks like the problem is because the carts browser session has not been refreshed once the items have been added to the cart. Due to the way that CodeIgniter sets its session data (Which holds the cart data), the new items added to the cart are only available once the webpage has been redirected. Since I think its probably a good example that should be available in the demo, I will try and include examples of adding items to the cart via ajax in the next week or so. However, if you want a pointer in the meantime, this will hopefully solve your problem. HTML Code: <input type="button" value="Buy Item" class="add_item" data-url="http://www.website.com/controller_name/method_name/101"/> JavaScript Ajax Code Code: $('.add_item').click(function(event) CodeIgniter Controller (In this example called 'controller_name') Code: function method_name($item_id = 0) Hope that helps you out for now.
[eluser]haseydesign[/eluser]
Hey PoetaWD, I don't know whether you solved your problem or not, but in any case, I've now updated the flexi cart demo with examples of adding items to the cart via Ajax. You can see a working example of this at http://haseydesign.com/flexi-cart/lite_l...x_examples The updates are available from the usual Github repo https://github.com/haseydesign/flexi-cart
[eluser]JoJo17[/eluser]
Hi This looks to be a great library and just what I need! I am having a little trouble with the discounts though and perhaps I'm not understanding it correctly but I can't get it working how I want. I want the discounts to be stored in the database and when a user enters the correct code for the discount it gets updated to their cart. What I have is: In the admin area of the site I have a specific discounts controller and the part that saves the discount codes to the database in the discounts model is thus: Code: public function add_discount() Code: $this->input->post('code') Code: $this->input->post('description') Code: $this->input->post('code_type') Code: $this->input->post('code_value') Code: $this->common_functions->get_timestamp() This does add the discount to the discount table. Within the shopping cart controller I have a function in the method that checks the entered code against the discount table: Code: public function promo_code() but it always returns: Discount code(s) is invalid. Discounts were not updated. even though the code is in the discount table. I just want to be able to set a discount of either a flat fee or percentage on the cart total (excl. shipping). I'm obviously misunderstanding this somewhere along the line and would appreciate if you could point me in the right direction please!
[eluser]haseydesign[/eluser]
@JoJo17 By the looks of your code you're doing everything right. I just tried doing some testing myself and was puzzled why I was getting the exact problem. What I'm betting on is that you are using the demo sql file, and due to an oversight by myself, the discounts are actually invalid - as in their expiry date has now passed. If you are using the demo sql file, what you need to do is update the expiry dates of these discounts. For a quick fix, try running the following sql to update all the demo discounts. Code: UPDATE discounts SET disc_expire_date = DATE_ADD(CURDATE(), interval 1 year); I will update the Github repo soon with the full SQL script.
[eluser]JoJo17[/eluser]
@haseydesign I'm not actually using the demo sql at all, I'm integrating flexi cart into an existing site. I have checked the expiry date of my discount (originally it was 0000-00-00 as I presumed I didn't have to set one) and have changed it to a date in the future but it still does the same so it must be a problem somewhere else. I have loaded up your demo SQL into a separate database so I can compare the differences!
[eluser]haseydesign[/eluser]
Hey JoJo, Have you tried using the example sql discount data within your own existing site? What I mean by that, is if you insert the example discount data into your sites discount table, they should be valid and prove whether there is either a library config problem, or a database data problem. To try this, backup/create a copy of your current discount table, and then run the following sql on the table named 'discounts'. Code: TRUNCATE `discounts`; You can now test the discount codes "10-PERCENT" and "10-FIXED-RATE". If that doesn't highlight the problem better, can you send me a dump of your discounts table. |
Welcome Guest, Not a member yet? Register Sign In |