- Posts: 251
- Thank you received: 2
set different carts for different product cat...
15 years 5 months ago #13256
by Nello
set different carts for different product cat... was created by Nello
It is possible to set different carts for different product categories and therefore be able to buy only products from that specific category?
Please Log in or Create an account to join the conversation.
15 years 5 months ago #13277
by nicolas
Replied by nicolas on topic Re: set different carts for different product cat...
There is no such option but could you explain a bit more what you're trying to do ?
Please Log in or Create an account to join the conversation.
15 years 5 months ago #13282
by Nello
Replied by Nello on topic Re: set different carts for different product cat...
OK, I try to explain.
I have Products A in Category A and Product B in Category B.
If I'm buying Product A I can't buy Product B in the same order, but first I have to complete the order of Product A of Category A and then I will be able to buy Product B.
I have Products A in Category A and Product B in Category B.
If I'm buying Product A I can't buy Product B in the same order, but first I have to complete the order of Product A of Category A and then I will be able to buy Product B.
Please Log in or Create an account to join the conversation.
15 years 5 months ago #13295
by nicolas
Replied by nicolas on topic Re: set different carts for different product cat...
It's not possible with an option but if you change a bit the code of the file show of the view product, you could load the categories of the products in the cart and only display the add to cart button when the category of the current product is the same as the products in the cart.
Please Log in or Create an account to join the conversation.
15 years 5 months ago #13300
by Nello
Replied by Nello on topic Re: set different carts for different product cat...
Uhmmm... Ok! I think I've understood! I'm going to study the code, but... if you want to post an example it would be wonderful.
You're great!
Anyway, thank you so much!
You're great!
Anyway, thank you so much!
Please Log in or Create an account to join the conversation.
15 years 5 months ago #13326
by nicolas
Replied by nicolas on topic Re: set different carts for different product cat...
Something like that (not tested):
Code:
$cart = hikashop::get('class.cart');
$products = $cart->get();
if(!empty($products)){
$ids = array();
foreach($products as $k => $row){
$ids[]=$row->product_id;
}
$db =& JFactory::getDBO();
$db->setQuery('SELECT category_id FROM '.hikashop::table('product_category').' WHERE product_id ='.$this->element->category_id);
$current_category_id = $db->loadResult();
$db->setQuery('SELECT category_id FROM '.hikashop::table('product_category').' WHERE product_id IN ('.implode(',',$ids).')');
$category_id = $db->loadResult();
if($category_id==$current_category_id){
//display add to cart
}
}
Please Log in or Create an account to join the conversation.
15 years 5 months ago #13419
by Nello
Replied by Nello on topic Re: set different carts for different product cat...
Thank you Nicolas
Please Log in or Create an account to join the conversation.
Time to create page: 0.162 seconds