Restrict Product Combinations

  • Posts: 62
  • Thank you received: 0
12 years 3 months ago #60963

I have a subscription product type which requires a specific payment type setup to do recurring direct debits. Because of this I need to restrict this product from being purchased with other normal payment type products. Since the payment type is determined by the Shipping Method I am trying to determine an appropriate way to restrict the available Shipping Methods based on the products in the cart. I seem to be coming up a little short on finding a solution that works for all or even most cart combinations. The key really is just that if the subscription product is in the cart then no other products should be.

If I make the weight on the subscription large and the shipping method for large weights this works in part. It stops the subscription shipping method from being displayed on most cart combos and shows it when the subscription product is in the cart. But does not stop other products form then being added because it just adds to the weight. If you then put upper limits it stops multiple subscriptions being added to the cart. The same sort of problems exist if I try anything to do with price.

Do you have any other ideas?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 3 months ago #61045

Hi,

You won't be able to restrict payment methods per products based on a characteristic which has to be used for shipping fees.
You should just add a check on the file 'cart' of the 'checkout' view via the menu Display->Views and add such code:

$sub_found=false;
$other_products=false;
foreach($this->products as $product){
 if($product->cart_product_quantity>0){
   if($product->product_code=='My_subscription_product') $sub_found= true;
   else $other_products = true;
 }
}

if($sub_found && $other_products){
 $app =& JFactory::getApplication();
 $app->enqueueMessage('Not possible');
 $this->nextButton = false;
}

The following user(s) said Thank You: Devine

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

  • Posts: 2
  • Thank you received: 0
  • Hikashop Essential
1 year 9 months ago #349219

HI,

I have about the same question, how to stop product combinations.

I have a subscription product type which requires a specific payment type setup to do recurring direct debits. Because of this I need to restrict this product from being purchased with other normal payment type products. Since the payment type is determined by the Shipping Method I use a warehouse to make the distinction. However I still have some challenges with my payment provider. Therefore I'm searching for a way to prevent a combination of the two products.

Is the solution below stil viable (now @ version 4.7.1) as it looks like e different structure is used now? Or can you give me a better direction to look into?

Kind regards,
Frans

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 9 months ago #349272

Hi,

The solution above is not possible anymore. This was with the old checkout system which was removed in HikaShop 4.0.0

Warehouses won't allow you to restrict the products in the cart.
If you want that the customers can't add another product in the cart when they add that product, I think you could use the limits system.
For example, you could set a weight of 99 999 kg for that product. Then, create a limit ( in the menu Products>Limits ) restricted to the "cart" with a max weight of 99 999 kg.
That way, when other products are in the cart, you won't be able to add this product to the cart. And when this product is in the cart, you won't be able to add other products as long as they don't have a weight of 0.

Alternatively, it's also possible to develop a custom plugin to prevent the add to cart based on custom conditions, implementing the onBeforeProductQuantityCheck event. We actually recently used that event in plugins/hikashop/shopclosehours.php to allow merchants to prevent users from being able to add some or all products to the cart base on the hour of the day:
www.hikashop.com/home/blog/492-hikashop-4-7-1.html#close

The following user(s) said Thank You: FransG

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

  • Posts: 2
  • Thank you received: 0
  • Hikashop Essential
1 year 9 months ago #349293

HI Nicolas,

Thanks for the elaborate answer including alternatives, much appreciated. I will have a look into it to find my solution.

Cheers,
Frans

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

Time to create page: 0.068 seconds
Powered by Kunena Forum