ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

flexi cart - A comprehensive shopping cart library for CodeIgniter

March 11, 2012 3:30am

Subscribe [36]
  • #16 / May 19, 2012 2:39am

    haseydesign

    171 posts

    @koichirose

    Sorry for the delay in reply - busy week.

    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.

    $this->lang->load('flexi_cart', 'italian');
      $this->load->library('flexi_cart');

    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.

  • #17 / May 19, 2012 11:39am

    Patrick Spence

    64 posts

    @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.

    I threw up the code I am using to talk to stripe here: https://github.com/ariven/stripe-integration-as-models

    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.

  • #18 / May 21, 2012 4:40am

    koichirose

    47 posts

    Sure, here it is: http://pastie.org/3943648

    I’m not a professional translator though.
    We’re planning to translate this to russian, too. I’ll send you that one when it’s ready 😊

    The language tip is working. I thought that once loaded in the model I couldn’t overwrite the language setting.

    Thank you once again!

  • #19 / May 22, 2012 9:10am

    haseydesign

    171 posts

    I have just released an update to the flexi cart library, which is available to download from the Github repo at https://github.com/haseydesign/flexi-cart.

    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.

  • #20 / May 28, 2012 1:07pm

    koichirose

    47 posts

    Hey, thanks for the credit.

    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.

    Can it be done somehow with flexi-cart?

    Thanks

  • #21 / May 29, 2012 6:37am

    haseydesign

    171 posts

    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);

    Function reference:
    cart_items() - http://haseydesign.com/flexi-cart/user_guide/cart_item_session_data#cart_items
    save_order() - http://haseydesign.com/flexi-cart/user_guide/order_set_data#save_order
    order_number() - http://haseydesign.com/flexi-cart/user_guide/cart_config_session_data#order_number

    —-

    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.

  • #22 / May 29, 2012 11:19am

    koichirose

    47 posts

    Thank you, I think I’ll go with this solution.
    I need the third table since I need to save split data for each store.

    I wanted to report a couple of what may be bugs:
    1. In your doc pages the anchors don’t seem to work (ex. this link is not taking me to the tax_total section: http://haseydesign.com/flexi-cart/user_guide/cart_summary_session_data#tax_total )

    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

    $shipping_data = array(
     'value' => 10 //example
    );
    $this->flexi_cart->set_shipping($shipping_data);

    Tax is 21%, set with

    $tax_data = array(
     'rate' => 21,
     'name' => 'VAT'
    );
    $this->flexi_cart->set_tax($tax_data);

    Results:

    $this->flexi_cart->item_summary_total(); // 44
    $this->flexi_cart->shipping_total(); // 10
    $this->flexi_cart->tax_name()." @ ".$this->flexi_cart->tax_rate(); //VAT @ 21%
    $this->flexi_cart->tax_total(); //11.34, calculated on €54
    $this->flexi_cart->total(); //65.34 (54+11.34)

    Results in a foreach cart items:

    $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.

    Thank you once again.

  • #23 / May 31, 2012 9:18am

    haseydesign

    171 posts

    @koichirose

    Thanks for the input.

    Issue #1: the broken link to http://haseydesign.com/flexi-cart/user_guide/cart_summary_session_data#tax_total
    This seems to work fine for me, perhaps your browser is jumping to the last position you were viewing on the page before a page refresh? - Or is there something I’m misunderstanding?

    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.

    Change the following line from:

    $value = (! empty($this->flexi->cart_defaults['shipping'][$column])) ? $this->flexi->cart_defaults['shipping'][$column] : $data;

    To:

    $value = (! empty($this->flexi->cart_defaults['shipping'][$column]) || $this->non_negative($this->flexi->cart_defaults['shipping'][$column])) ? 
      $this->flexi->cart_defaults['shipping'][$column] : $data;

    I haven’t had a chance to properly test this yet, so if things are still weird, let me know.

  • #24 / Jul 16, 2012 3:29pm

    Nassau Sky

    3 posts

    Hi,


    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.

    Any ideas what maybe I’m missing?

    Thanks,
    Mike

  • #25 / Jul 17, 2012 7:11am

    haseydesign

    171 posts

    Hi Mike,

    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

    $config['sess_use_database'] = TRUE;

    If that doesn’t help and you haven’t done so already, install a brand new installation of CI and then run through the flexi cart step by step installation guide http://haseydesign.com/flexi-cart/user_guide/installation

    Let us know if your still struggling.
    Good luck.

     

  • #26 / Jul 17, 2012 10:13pm

    Nassau Sky

    3 posts

    99% there. Like you said, changing from false to true worked for most items.

    $config[‘sess_use_database’] = TRUE;  // <——Great

    but it’s odd that none of the items via links work (the 100 series) am I missing something else that you can think of. 

    Thanks!

  • #27 / Jul 18, 2012 7:51am

    haseydesign

    171 posts

    Hey again Mike,
    it’s a little odd that the ‘items via links’ are not working whilst the other examples are.
    The item form examples essentially work in the same manner, so the library files will be working okay.

    I would suggest the best way to diagnose the problem is to start the flexi cart demo from scratch, by setting up a brand new CI installation, and then running through the flexi auth installation guide http://haseydesign.com/flexi-cart/user_guide/installation.
    I know i’s a little long to read but it is all pretty essential in order for the library to work.

  • #28 / Jul 18, 2012 7:53am

    haseydesign

    171 posts

    Duplicate post

  • #29 / Jul 18, 2012 8:07pm

    Nassau Sky

    3 posts

    OK I will trudge through it again. I was praying it was something simple. I looked through the instructions and did notice I missed a part that mentioned the session and didn’t notice that I missed anything else. I will have to do it again and see where it leads.

    Thanks I will let you know either way how it works out.

  • #30 / Aug 08, 2012 9:17am

    Valcsi

    5 posts

    Hi there,

    Does anyone have any idea why I get this error when I view the content of the cart?

    A PHP Error was encountered

    Severity: Warning

    Message: Creating default object from empty value

    Filename: models/flexi_cart_lite_model.php

    Line Number: 41

    Which is this line:

    $this->flexi->cart = $this->config->item('cart','flexi_cart');

    I can see the items added to my cart with all the info, but I have no idea how I could fix this issue. The configs file look good, the SQL database works, the session looks OK.

    Any ideas? I would really appreciate any help. Thanks

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases