EllisLab text mark
Advanced Search
5 of 10
5
   
flexi cart - A comprehensive shopping cart library for CodeIgniter
Posted: 26 October 2012 10:22 PM   [ Ignore ]   [ # 61 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

@AlwynW

This problem is usually caused if you are not saving session data to a database.

This is defined via a config setting in the CI config file.

$config['sess_use_database'TRUE

For the this to work, you have to also ensure the session database table has been created.
Read more at http://ellislab.com/codeigniter/user-guide/libraries/sessions.html under the subheading Saving Session Data to a Database

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 28 October 2012 06:36 PM   [ Ignore ]   [ # 62 ]   [ Rating: 0 ]
Joined: 2012-10-25
3 posts

Again thanks for taking the time to look at my question. It seems to be a combination of things I did wrong (got the settings right after all). Note to self, make sure you only load the library once. I did a load on construct and another in the controller function which messed it all up. I figured it out and everything works as expected now!

Another question though, is it possible to configure the following system, either with points or vouchers and what would be the best way to go:

Each purchase grants the user a discount of 2% of the amount (of the current sale) for the next purchase. The user should be able to save these discounts until they want to use it (after each next purchase the discount adds to the existing one).
So it’s not mandatory they use it for a next purchase.
I think the point system is not really useful for this or I had to abuse it so each point is in fact 1 euro/dollar.

 
Posted: 30 October 2012 05:18 AM   [ Ignore ]   [ # 63 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

Hey again AlwynW,

The libraries reward point feature would not really be suitable for the functionality you have outlined as it is intended to be monetary based.

However, there would be nothing stopping you creating a new discount every time the user placed an order that was linked to the users id. The discount could then be defined with a voucher code so that the user can then redeem the voucher when they wish.
Upon creating the discount, you could check whether the user had an existing discount, and then just up the percentage as required.

Whilst this is possible, I will advise you that incrementing the discount as you have described without any other conditions would be a very bad idea. All I would need to do is place 50 separate orders for the cheapest item on the site. This would increment my discount to 100% (50 orders x 2%), I could then place another order for everything on your site with a 100% discount - free!
So just make sure you have some conditions capping the percentage at a maximum limit.

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 06 November 2012 06:46 AM   [ Ignore ]   [ # 64 ]   [ Rating: 0 ]
Joined: 2012-11-06
2 posts

Hi when i add items to cart in the demo the cart is shown empty in view cart. plz help

 
Posted: 06 November 2012 07:06 AM   [ Ignore ]   [ # 65 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

@harpreets

Refer to my post above to AlwynW and the solution he came up with, that appears to be the most common cause.

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 06 November 2012 07:07 AM   [ Ignore ]   [ # 66 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

Duplicate post

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 06 November 2012 07:19 AM   [ Ignore ]   [ # 67 ]   [ Rating: 0 ]
Joined: 2012-11-06
2 posts

Thanks for timely reply.

 
Posted: 12 November 2012 06:23 AM   [ Ignore ]   [ # 68 ]   [ Rating: 0 ]
Joined: 2009-05-11
52 posts

Hi, I have a few questions about discounts:

- It seems I can’t set discounts for a group of users (users of a certain group, an array of user_ids, etc). Is that correct? How should I correctly integrate this functionality with flexi?
- On a related note: can I insert a discount code redeemable only once per user?

Thank you

 
Posted: 12 November 2012 07:36 AM   [ Ignore ]   [ # 69 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

Welcome back koichirose,

There is no specifically defined discount column to handle a user group id.
Instead, there are 3 custom status columns that you can define whatever data you want into them - e.g. A user group id.

Within the database discount table, you could for example define the ‘custom_status_X’ as ‘3’ (User group id = 3).
This would mean that the discount could only be applied to users that are in a user group with the id of 3.

- But how do you set the user group id within your php?
You can use the set_custom_status_X() function to define the user group id to the library session. It will then allow discounts with a ‘custom_status_1’ column value of ‘3’.

If you need to get the current custom status defined within the library session, you can use the .(JavaScript must be enabled to view this email address) function.

There are upto 3 custom statuses that you can define per discount.

—————————————————————————————————————————

Regarding limiting discounts to 1 per user, I seem to remember that I pondered on adding this as a feature, but never implemented it as it is too easy for a user to circumvent.
Basically the library would check whether the users id had ever completed an order with the discount active, if so it would invalidate the discount.

All you would need to do to get around this is create another account to get another user id.

If you wanted to add this yourself, you would need a little custom code.
Save the discount id within the order details table, when a user adds a discount, check whether the specific discount id and user id exist within the table - if so, deactivate the discount.

HTH

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 12 November 2012 10:25 AM   [ Ignore ]   [ # 70 ]   [ Rating: 0 ]
Joined: 2009-05-11
52 posts

Thank you very much, I’ll look into that as soon as possible.

Right now we’re trying to get it to work. We managed to use 7 as ‘disc_method_fk’ (Summary Item Total - Percentage Based). This works as expected.

I’d like to try the item/group item based ones.
So I put 1 as ‘disc_method_fk’. The documentation about ‘disc_item_fk’ says “The value CAN be used to act as a foreign key relating the table to the primary key of a custom item (product) table, although this is not joined by default.”

I think I’m missing something from the documentation, I can’t find where to join tables and what value to put as ‘disc_item_fk’. Being a FK, I suppose I’d have one id per item.
Does it mean that if I want to create a discount for 15 different products I’d have 15 identical rows (except, of course, for ‘disc_item_fk’) ?

What if I want discount codes for an entire product category?

Finally (for now smile ), I see that ‘disc_usage_limit’ is NOT NULL and the query checks for it being > 0.
Can I just set that to no limit, meaning a code doesn’t have a usage limit, but only an expiration date?

Thank you again


EDIT: I’m trying to use ‘update_discount_codes()’ instead of ‘set_discount_codes()’ as I only want one code at a time, but it doesn’t seem to work.

var_dump($this->flexi_cart->discount_codes());
//output:
array
  
'TEST' => 
    array
      
'id' => string '1' (length=1)
      
'code' => string 'TEST' (length=4)
      
'description' => string 'Test description' (length=16

I then try to use update_discount_code(‘TEST_20’); and I get two discount codes (TEST and TEST_20).
It seems it’s not entering in this if:

if (! empty($this->CI->flexi->cart_contents['settings']['discounts']['codes'])) 

It’s in flexi_cart_model:3342 .

 
Posted: 13 November 2012 07:49 AM   [ Ignore ]   [ # 71 ]   [ Rating: 0 ]
Joined: 2012-08-08
5 posts

Hi haseydesign,

Over the weekend I finally had the time to give flexi cart a try. I’ve managed to put it all together, and everything seems to work apart from displaying the email address from the saved database entry. I can see the order number, and the query that uses it to retrieve the email address, but it returns an empty array. Strange. (as a side note, if order confirmations are displayed like 0000001,0000002 it is really easy for anybody to find email addresses from the database - I know you would have a payment gateway, and you can use a random number….)

Another thing that I’m trying to figure out is how to split items into separate carts. For example: blue items would go into one cart, green items would go into a second cart, and red items would go into a third cart. The user would check out each cart separately. Is it something flexi cart would be able to handle?

Thanks

 
Posted: 14 November 2012 05:21 AM   [ Ignore ]   [ # 72 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

@koichirose

Lots of questions there koichirose, let me try and address them individually.

Item Group Discounts
The ‘disc_item_fk’ column is only used to define a discount for a specific item.
If you would like to apply a discount to a group of items, you would use the ‘disc_group_fk’ column.

This column would then link to the ‘disc_group_id’ column within the ‘discount_groups’ table. Each row within this table is the wrapping group for items to be inserted into.

Then the ids of the items you want to group discount are added to the ‘disc_group_item_id’ column within the ‘discount_group_items’ table.

When you then add an item to the cart, it will automatically check through the foreign key relationship between the 3 tables and check whether the item id exists within the ‘discount_group_items’ table. If the discount conditions are valid, the discount will be applied for the item.

I will also point out that the library also includes functions to help you manage discount item groups.
http://haseydesign.com/flexi-cart/user_guide/discount_admin#insert_db_discount_group
http://haseydesign.com/flexi-cart/user_guide/discount_admin#insert_db_discount_group_item

A demo of adding items to a discount group using a custom SQL WHERE builder can be found at:
http://haseydesign.com/flexi-cart/admin_library/insert_discount_group_items/1
http://haseydesign.com/flexi-cart/user_guide/custom_sql_admin#create_sql_where


Defining an Infinite Discount Limit
This is not possible with the current design of the library, instead you will just need to put a large value into the ‘disc_usage_limit’ column.
If the quantity is 0 or null, the library will detect the discount offer as no longer being available.


Allowing Only 1 Discount Code
Thanks for pointing out this bug. I’ve updated the Github repo with a fix to solve this problem.
Only the /models/flexi_cart_model.php file needs to be updated.

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 14 November 2012 05:54 AM   [ Ignore ]   [ # 73 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

@Valcsi

There are a few points that I need to confirm you are aware of.

You say that if order numbers are incremental, that other users would be able to simply enter an order number into the url to get specific details of an order - including email addresses.

You need to ensure that these pages are not accessible to unauthorised users. Only users that have logged in as an admin should be able to see all orders, and customers should only be able to see order details for their own orders.

If an unauthorised user should enter a valid url to view someone else’s order, they should not be shown the order details. This functionality needs to be provided by your user authentication library - may I plug my own flexi auth library if you’re interested.

The security of the order details is not compromised by having incremental order numbers provided you follow the steps outlined above. However, it is also possible to generate random order number or to even define you own.

Define the flexi cart to generate random order numbers by setting the following config setting via the flexi cart config file.

$config['defaults']['configuration']['increment_order_number'false

You can alternatively define this via the ‘cart_config’ database table and ‘increment_order_number’ column.

To define your own order number, you can define it when saving the rest of the order via the ‘order_number’ argument on the ‘save_order()’ function.
http://haseydesign.com/flexi-cart/user_guide/order_set_data#save_order

—————————————————————————————————————————————————-

Regarding not being able to retrieve the email address within an order details, first ensure that the data is being saved to the database in the ‘order_summary’ table.

If the data isn’t being saved, review the code within the demo for the ‘demo_save_order()’ method within the ‘model/demo_cart_model.php’ file for saving custom order data.

If the data just isn’t being returned, review the code within the demo for the ‘order_details()’ method within the ‘controller/admin_library.php’ file for getting saved order data.

—————————————————————————————————————————————————-

Finally regarding saving items into multiple different carts, I can’t say I’ve ever come across a need to do this. However, I guess you could probably use the libraries load/save cart feature to achieve something like what you’re after.

You can see a demo of this at http://haseydesign.com/flexi-cart/standard_library/load_save_cart_data

Hope that all helps

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 14 November 2012 06:52 AM   [ Ignore ]   [ # 74 ]   [ Rating: 0 ]
Joined: 2009-05-11
52 posts

Hi,

Thank you for your answer.

I’m leaving the discount codes aside for a moment, as updating the model brought up a new bug about shipping tax rates (I see there’s a commit in May about this), either on your or my side.

Here’s what I’m doing:

$total_shipping $this->m_mkt_cart->calculate_shipping($cart_items);
$shipping_data = array(
 
'value' => $total_shipping['shipping'//value has no tax here
);

//get tax rate based on current country
$tax_data $this->m_mkt_misc->get_tax_rate_by_country_id($this->settings->mkt_country_id);
/* tax data is:
array
  'rate' => int 21
  'name' => string 'VAT' (length=3)
*/
$this->flexi_cart->set_tax($tax_data);
$this->flexi_cart->set_shipping($shipping_data);
var_dump($this->flexi_cart->cart_summary());
/* output:
array
  'item_summary_total' => string '€ 82.64' (length=9)
  'item_summary_savings_total' => string '€ 0.00' (length=8)
  'shipping_total' => string '€ 14.74' (length=9)
  'item_shipping_total' => string '€ 97.38' (length=9)
  'summary_savings_total' => string '€ 0.00' (length=8)
  'savings_total' => string '€ 0.00' (length=8)
  'reward_voucher_total' => string '€ 0.00' (length=8)
  'surcharge_total' => string '€ 0.00' (length=8)
  'tax_total' => string '€ 17.35' (length=9)
  'total' => string '€ 114.73' (length=10)
  'total_rows' => string '1' (length=1)
  'total_items' => string '1' (length=1)
  'total_weight' => string '0g' (length=2)
  'total_reward_points' => string '826' (length=3)
*/ 

As you can see, ‘total’ is (item_summary_total + tax) + shipping. No tax is applied to shipping.

According to the documentation of the ‘set_shipping()’ function, it should apply the cart tax rate:

‘tax_rate’ - Tax rate applied to the shipping rate, the carts tax value is used if no value is submitted. Submitted values must be numeric.


I could fairly easily add a ‘tax_rate’ field to the $shipping_data array, but I wanted to point out a possible bug.

Could you verify this?

Thanks again

p.s. anchors on the doc site still don’t work on firefox (verified both on osx and windows). they are fine on chrome. I guess you can’t do anything about it smile


EDIT: I see I have this in my config file:

$config['defaults']['shipping']['tax_rate'0

I guess this is the value it uses, instead of the cart one. Is this by design?

EDIT2: it doesn’t use that. I solved for now by manually setting a ‘tax_rate’ value for $shipping_data.

 
Posted: 15 November 2012 06:50 AM   [ Ignore ]   [ # 75 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

@koichirose,

From the code you have posted, you look like you worked it out that it is the config setting

$config['defaults']['shipping']['tax_rate'

that defines the tax rate for manual shipping options (Database shipping option tax are defined via the table).

However, by default, that config setting is defined as FALSE (Not ‘0’ as you have), which means that the default cart tax rate is used.
If ‘0’ is set, then it defines that no tax should be applied to the shipping rate.

I see that you dismissed this with your EDIT2 comment, but that is how it is intended to work, and from my testing within the available demo example, it proves to work as expected.


One note that I must warn that always throws me off, is that internally, the cart calculates all pricing excluding tax.
The all important config setting to understanding this is:

$config['defaults']['configuration']['price_inc_tax'

If set to TRUE and a $10.00 shipping option is added including 10% tax, the cart will calculate the shipping rate excluding tax as $9.09 ($10 / 10%) and $10.00 including tax.
If the config setting was FALSE, the the shipping option excluding tax would be $10.00 and including tax would be $11.00 ($10 x 10%).

To further complicate matters, remember that you can then further manually define whether to display pricing inc/excluding tax.

 

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
5 of 10
5