Page 1 of 1

Fetch product_id in Shipping Method part

Posted: Tue Oct 01, 2013 11:09 am
by IT_MAN
Hi to all. It's been a while since I last posted here in the forums. I have been using, modifying and customizing several OC based cart sites, I just have this one inquiry regarding the shipping method part in checkout. I want to filter something in that part using the product_id of the items in the cart, but I can't even make it appear in the page. Can someone help me? Thanks in advance!

Re: Fetch product_id in Shipping Method part

Posted: Tue Oct 01, 2013 10:01 pm
by Qphoria
You'll have to edit the catalog/model/shipping/xxx.php file

to get the individual product ids you'll use:

Code: Select all

foreach ($this->cart->getProducts() as $product) {
    if ($product['product_id'] == 24)) {
        // do something
    }
}

Re: Fetch product_id in Shipping Method part

Posted: Tue Oct 08, 2013 1:43 pm
by IT_MAN
Qphoria wrote:You'll have to edit the catalog/model/shipping/xxx.php file

to get the individual product ids you'll use:

Code: Select all

foreach ($this->cart->getProducts() as $product) {
    if ($product['product_id'] == 24)) {
        // do something
    }
}

Thank You very much!! I will try this now!!

Re: Fetch product_id in Shipping Method part

Posted: Tue Oct 08, 2013 2:21 pm
by IT_MAN
Is it possible to filter the shipping method by the product_id in the checkout part? Like when they order product no 1, with product_id of 1, I will show this shipping method A. That's the main scenario I want to happen. Is there a way how to make it happen? Thanks in advance!

Re: Fetch product_id in Shipping Method part

Posted: Tue Oct 08, 2013 10:37 pm
by Johnathan
Not sure if you're interested in a commercial extension, but Restrict Shipping Methods can do what you want.