VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: normangreen on May 13, 2015, 05:26:45 AM

Title: assign specific payment or shipment method to specific product
Post by: normangreen on May 13, 2015, 05:26:45 AM
hello

If I have three products named product-A, product-B, product-C and two payment methods named payment-I, payment-II and two shipment methods named shipment-1,shipment-2.

Then I want the product-C can only use the payment-II and shipmet-2, there is no other payment and shipment method(payment-I and shipment-1) for customers who buy product-C to choose.

My objective is to let the specific product in the checkout process can only use the specific payment or shipment method for coustomers.

How can I configure to achieve the objective?

Thank you.
Title: Re: assign specific payment or shipment method to specific product
Post by: rinopiponte on May 14, 2015, 10:20:40 AM
I had the very same problem in my shop, because I combine several kinds of products at http://design-it.es (http://design-it.es).

This is a trick, but you have to be very careful because it implies changing the code of virtuemart core

* For shipment its easy if you set different ranges of shipment depending on weight, for example Product A with shipment A only if PA weights less than 100Kg, PB with SB if it weights less than 50Kg and PC if it weight less that 25Kg. If you can set these conditions without impacting on other areas you have it solved. You have to change shipment plugin

* For payment you will have to change the code at /components/com_virtuemart/views/cart/tmpl/select_payment.php
For each product at line 26 you'll have to write

You have to set a tick for example if it is a category:

foreach ($this->cart->products as $pkey => $prow) {
if ( $prow->virtuemart_category_id == 'XXX'){
$TICK = 1;
}
}


or for a single product


foreach ($this->cart->products as $pkey => $prow) {
if ( $prow->product_name "Or $prow->url or whatever"== 'XXX'){
$TICK = 1;
}
}


Then depending on your shipment order, you'll have to select for each tick only the shipment method you want to display.

Do this only if you can code using php, and of course backup the modified files before changing a single character.

Hope this helps
Title: Re: assign specific payment or shipment method to specific product
Post by: reinhold on May 14, 2015, 12:36:58 PM
Regarding shipping: With my Advanced Shipping by Rules plugin (http://open-tools.net/virtuemart/advanced-shipping-by-rules.html) it is realy easy to hide a shipping method if a particular product is in the cart.

You can make your shipping method unavailable for a product by prepending this rule to the method's rules for shipment-1:

Comment="No shipment-1 for product C"; contains_any(SKUs, "product-C"); NoShipping
...[here come your other rules for the shipping method]...

This will simply not offer the method if product C is in the cart. If product C is not in the cart, the method might offer shipping if the next rules match.

Regarding payment, I have no idea how you can easily implement this without modifying the VM code itself.

Best regards,
Reinhold
Title: Re: assign specific payment or shipment method to specific product
Post by: Dragoner on June 29, 2018, 13:17:35 PM
Hi, is this funcional in vm3?

foreach ($this->cart->products as $pkey => $prow) {
if ( $prow->virtuemart_category_id == 'XXX'){
$TICK = 1;
}
}


Pls can you send me your file select_payment.php

Thank you
David
Title: Re: assign specific payment or shipment method to specific product
Post by: Studio 42 on June 29, 2018, 13:37:38 PM
You have https://alatak.net/en/extensions/virtuemart/shipments/pro-shipment-plugin.html
And my own https://shop.st42.fr/en/tools/shipment-rules.htm with filters by product fields or custom fields.
Title: Re: assign specific payment or shipment method to specific product
Post by: Dragoner on July 25, 2018, 14:34:37 PM
Shipment rule is nice, but i need only payment rules.

Somethink like this ... I have two products

Product 1 and product 2
Product 1 ... payment only by credit card
product 2 ... payment by credit cart and cash

If i get to cart product 1 and product to, payment must be only credit card ...
Is it possible?


Sorry for my english :)
Thanks David
Title: Re: assign specific payment or shipment method to specific product
Post by: Studio 42 on July 25, 2018, 14:50:32 PM
You can use categories as filter in the shipment methods.
Check if the plugin developer can add this restrictions in your payment methods, so you can use categories to restrict the displayed methods.