Product Custom Fields and Add to Shopping Cart

  • Posts: 15
  • Thank you received: 0
  • Hikashop Business
13 years 9 months ago #11075

The site I am building is used for sports program registrations. There is a requirement to capture registrant information (name, age) which I am attempting to do using custom fields in the product as per post #6722. The mechanism captures the information properly and works through to purchase.

The problem is in adding a second copy of the same product (second individual being registered for the same program) to the shopping cart. It is added as a separate item in the shopping cart which means that the volume discount pricing mechanism for the product no longer works. I suspect that this is because of the custom fields.

Is there any simple way to make this work as expected?

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 9 months ago #11082

Indeed, when you use custom item fields, each entry in the cart is then handled separately from the other which is why you get that result.
What kind of volume discount pricing are you using ? Coupons, discounts or prices with minimum quantities ?

Last edit: 13 years 9 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
  • Hikashop Business
13 years 9 months ago #11120

The volume discount mechanism I want to use is prices with minimum quantities. I do not know in advance how many registrants a particular order will have. As an example: families commonly register more than one child but the number of children can vary from season to season depending on what else they are involved in. Families registering can also change season to season. Use of a coupon mechanism to address this volume discount requirement would be logistically challenging.

Note that I do use the coupon mechanism for providing discounts based on previous volunteer work. That works as expected and as desired.

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 9 months ago #11130

Could you try to replace the code:
foreach($cart->products as $k => $row){
$currencyClass->quantityPrices($cart->products[$k]->prices,@$row->cart_product_quantity,$main_currency);
}

by:
$product_quantities = array();
foreach($cart->products as $row){
$product_quantities[$row->cart_product_id]+=(int)@$row->cart_product_quantity;
}
foreach($cart->products as $k => $row){
$currencyClass->quantityPrices($cart->products[$k]->prices,$product_quantities[$row->cart_product_id],$main_currency);
}

in the file administrator/components/com_hikashop/classes/cart.php ?

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
  • Hikashop Business
13 years 9 months ago #11141

I've implemented the suggested change and it doesn't seem to have any effect. The result is still separate entries in the shopping cart if the custom field entries are different. The minimum quantities does work if I enter successive entries where the custom fields are same (ie same name and age) but doesn't if the entries are not successive.

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 9 months ago #11158

Yes, the entries will still be separated in the cart, BUT the prices should use the global quantity of the product. Isn't that the case ?

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
  • Hikashop Business
13 years 9 months ago #11171

The results are mixed. I've tried a number of scenarios in adding the same product (with varying details for first name, last name and age) with results as follows:

    - person 1, person 2, person 3 - all individual details different: separate entries in cart with base price;

    - person 1, person 2, person 3 - person 1 and 2 the same with person 3 different: two entries in cart with first entry reflecting price for ordering quantity of 2 and second entry reflecting free;

    - person 1, person 2, person 3, person 4 - in order with person 1 and 3 the same and person 2 and 4 the same: two entries in cart with first entry reflecting price for ordering quantity of 2 and second entry reflecting free

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 9 months ago #11174

Could you give us a link to your website with that product page and a FTP access so that we can directly test our modifications there directly and not bother you each time we try something ?

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
  • Hikashop Business
13 years 9 months ago #11176

One of the product pages is: www.go-hsa.ca/index.php?option=com_hikas...y_pathway=14&lang=en .

The product is set up with pricing as follows:

    $117CDN with minimum qty of 0
    $100CDN with minimum qty of 2

I have set up an FTP account. Can you give me an email address to which to send it to?

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 9 months ago #11184

You can send it via our contact form: www.hikashop.com/en/support/contact-us.html

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 9 months ago #11245

Ah I see, the module cart handles that somewhere else from the main cart.
You need to edit the file components/com_hikashop/views/product/view.html.php and change the code:
foreach($rows as $k => $row){
$currencyClass->quantityPrices($rows[$k]->prices,@$row->cart_product_quantity,$main_currency);
}

to:
$product_quantities = array();
foreach($rows as $row){
if(empty($product_quantities[$row->cart_product_id])){
$product_quantities[$row->cart_product_id] = (int)@$row->cart_product_quantity;
}else{
$product_quantities[$row->cart_product_id]+=(int)@$row->cart_product_quantity;
}
}
foreach($rows as $k => $row){
$currencyClass->quantityPrices($rows[$k]->prices,$product_quantities[$row->cart_product_id],$main_currency);
}

I couldn't do it with your FTP access since yu only gave me access to the back end files of hikashop.

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
  • Hikashop Business
13 years 9 months ago #11246

It still doesn't seem to be working. I am getting results similar to the change of the cart.php file (which I have reverted). I have expanded your ftp access so you should now be able to access the front-end files.

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 9 months ago #11253

Ok. It's getting late around here so we'll look at that tomorrow.

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 9 months ago #11325

Hi,

The problem is fixed now on your website and will be included in next version of HikaShop. There were a bit more modifications to do in other places so that it works properly.

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
  • Hikashop Business
13 years 9 months ago #11355

Great! Thanks very much - the effort is appreciated!

Please Log in or Create an account to join the conversation.

Time to create page: 0.078 seconds
Powered by Kunena Forum