I don’t really understand how to offer a seamless experience for both logged users and guests.
Examples:
- A guest puts items in the cart. The guest logs in -> items are saved to the db in addition to the session. (I guess I could manage this in the login function, calling save_cart_data() right there, or is there something better?)
- A guest wants to view his cart -> load items from the session. (this works great)
- A logged-in user wants to view his cart -> load items from the db (this I don’t understand: saved cart data on the db doesn’t include some fields. This is the same product saved in the session and saved on db and unserialized:
To give you some idea of whats happening there, session data and database data purposely contain different data.
The session needs to contain much more data that is used internally by the library to help work out whats happening with the live data within the cart, whilst the database data is a primarily a readable summary of order data.
It is possible to save an order to the database, then close your browser (so the session data is deleted) and then reload the saved database data back into the users session.
When reloading the database data back into the session, the library internally repopulates all of the ‘missing’ fields - however, you must use the libraries functions to do this.
To see an example of this feature in action, try out the following page : http://haseydesign.com/flexi-cart/standard_library/load_save_cart_data
Note that currently, only the third date list in ‘‘Load Saved Cart Data’ is working (A cockup by me trying to fudge the serialized strings using SQL rather than the library - this error should not happen when using the library and affects this demo only).
If you add some items to your cart, then save the cart via this page, then load another cart, you will be able to see the feature in action.
The above page allows a user to save their cart session to the database and then reload it again from the database into their current browser session.
This demo page and its functionality can be viewed via the ‘load_save_cart_data’, ‘save_cart_data’ and ‘load_cart_data’ methods in the ‘standard_library.php’ controller.
The user guide page http://haseydesign.com/flexi-cart/user_guide/database_cart_data_admin details the functions required for this feature.
If all is still not clear, let me know.
Cheers,
Rob
For now I’m trying to set the language, so I created another folder (inside application/language), pasted flexi_cart_lang.php and translated everything.
I’m having trouble loading the correct lang, since I’m setting a codeigniter variable in a hook - i.e. I do:
Inside __construct though I can’t use $this, nor get_instance, so I don’t know how to access that variable.
I see there’s a &__get() function in that model, but I don’t understand if it could help me.
1) flexi cart doesn’t currently have any payment gateways built into the library.
I have personally integrated flexi cart with WorldPay and have had no problems.
It’s just a case of reading through the payment gateways api documentation, and then using flexi carts functions to pass the required data.
If and when I get the time, i’ll try and look into creating some demos for popular gateways like PayPal.
If you end up implementing it with a gateway, i’d be interested if you were happy to share the code.
I just finished a small shopping site (unfortunately without your cart) using Stripe as a payment processor. it was very easy to integrate. And you can get an account without giving them financial data to let you test things out with charging, customers, coupons, subscriptions, etc.
/ not an employee of Stripe
// Not striped either.
Firstly, what you have done regarding copying the ‘english/flexi_cart_lang.php’ file to ‘italian/flexi_cart_lang.php’ and translating the file is correct.
As for the hook, I’m not too familiar with using hooks in CodeIgniter, and from a quick attempt myself, I see your problem.
However, do you really need to set the language via a hook?
Typically, if you want to set a specific language you can define the language via CodeIgniters config.php file, by setting
$config['language'] = 'italian';
If you need a more variable solution, so that for example the language could be changed by a user on the site, you can define the language to use via the __construct() of the controller, just before the flexi cart library is loaded.
Would this be suitable?
Would you mind sharing the translated Italian language file with the library? I’ll be sure to credit your name to the file.
————————————————————————————————————————————————
@Patrick Spence
I’ve seen Stripe being mentioned about a fair bit.
As you say, the problem with developing for alot of payment processors is needing to create a financial account, but since you say Stripe doesn’t require this, i’ll have to give it a look when I get some time.
@Patrick Spence
I’ve seen Stripe being mentioned about a fair bit.
As you say, the problem with developing for alot of payment processors is needing to create a financial account, but since you say Stripe doesn’t require this, i’ll have to give it a look when I get some time.
They really were easy to work with, only took me a couple days to type it all in. I have it active on one ecommerce site now, and am in the middle of integrating in another. Its taking me longer to create the forms and do program logic on the site rewrite than it does to integrate the charging.
One advantage to stripe is that you can use their javascript method to grab a card token, so the customers credit card doesn’t have to hit your server… so less issues with PCI-DSS and hacked sites.
Though you CAN grab the card and get a token via php.
The update includes some improvements to how status and error messages are returned by some of the internal functions within the library.
As well as specifying whether a message should only be displayed to either public or admin users, there is now a config option to prevent specific messages from being set at all.
Additionally, there are now additional language files that the libraries status and error messages can be displayed as.
The languages are Italian (Thanks @koichirose for this), French, German and Spanish.
For further information on these changes, please refer to the change log and user guide.
I just saw that the save_order function saves on two db tables (order_summary and order_details).
I need to introduce a third table in between, ex.:
order_summary has an order_id (autoincrement) = 23
order_store has an order_summary_id = 23 and an order_store_id (autoincrement) = 54
order_details has an order_store_id = 54 and an order_details_id (autoincrement) = 187
This is necessary for a multi-store e-commerce site.
Hey again koichirose,
What I would do in the scenario you have outlined is as follows.
1. Before you call the save_order() function, insert an empty record into your custom order_store table using CI’s standard SQL functions.
2. Get the insert_id for the new table row.
3. Call the save_order() function and pass the insert_id to the save_order() functions $custom_item_data parameter - this will save the id of your order_store table to each item row in the order_details table.
4. When the save_order() function has saved the data, use the order_number() function to get the unique id (The order number) of the order_summary table.
5. Update your custom order_store table with the order_number value.
This should mean that your custom order_store table now has the unique id of the order_summary table, and the multiple newly added rows in the order_details will have the unique id of your order_store table.
Here’s a rough example (Not tested)
// Insert record to custom order_store table. // Insert whatever data you need, the aim is just to insert a record and get the id of the new row. $order_store_data = array(...); $this->db->insert('order_store', $order_store_data); $order_store_id = $this->db->insert_id();
// Now we need to add the insert_id to each item row within the order_details table. // To associate the insert_id with each item, we need to loop through the items that are in the cart and create an array. // Use the cart_items() function to return an array of all cart items that we can then loop through. $custom_item_data = array(); foreach($this->flexi_cart_admin->cart_items() as $row_id => $item) { $custom_item_data[$row_id]['order_store_id'] = $order_store_id; }
// Now use the save_order() function with the $custom_item_data array. $this->flexi_cart_admin->save_order(false, $custom_item_data);
// Get the order number of the newly added order (i.e. The unique id of the order_summary table) $order_number = $this->flexi_cart_admin->order_number();
// Update your custom order_store table with the unique id of the order_summary table. $sql_update_data = array('order_summary_id' => $order_number); $sql_where = array('order_store_id' => $insert_id); $this->db->update('order_store', $sql_update_data, $sql_where);
Without knowing your full scenario, I will point out that it may be better/easier to just associate the order_store_id with the single row in the order_summary table, rather than for each order_details row.
Each row within the order_details table could then get the order_store it is assoicated to by using the parent order_summary table.
But hey, thats just a suggestion, it may not be suitable for what you’re doing.
2. It seems that the shipping is taxed even though $config[‘defaults’][‘shipping’][‘tax_rate’] = 0;
Example:
I’m adding one item to my cart (€22), quantity: 2 (€44), shipping is €10, set with
$this->flexi_cart->item_tax_total($row_id, false, false, false); //9.24, calculated on €44, without shipping
I’m guessing the 11.34 is wrong - tax has to be calculated on products without shipping.
Or viceversa. Actually, maybe 11.34 is correct and 9.24 is not.
How can I set this? I am not (yet) using a shipping db table, but even then I’ll still set shipping rate as shown above.
Issue #2: Shipping tax rate set as ‘0’ via the config file is being ignored.
This was definitely a bug, the value ‘0’ was being treated as FALSE, and so was being ignored.
I have fixed this problem and made the change to the Github repo.
If you’d prefer to just change the errornous line, its located on line 2060 within flexi_cart_model.php.
Flexi-cart library looks very nice but after I got it installed, everything is looking good except no items can be added to the cart. No errors either, it just returns to the view after I click on any of the examples such as Example 101 , Example 102 etc.
Since you seem to suggest that the installation is generally working okay - i.e. there being no errors - I would presume the problem to be with either CI’s sessions or the database setup.
I will take a guess that maybe the ‘sess_use_database’ setting in CI’s config/config.php file is not set as ‘true’.
It MUST be set as