Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Shipping based on Product type?

Shipping based on Product type?

Views: 1,919

Results 1 to 7 of 7
11 Jul 2011, 1:28 PM
#1
snowgoose avatar

snowgoose

New Zenner

Join Date:
Jul 2011
Posts:
21
Plugin Contributions:
0

Shipping based on Product type?

I am new to zen cart but have set up a shop ( which seems to be working ok )

I just want to set up shipping based on product types if possible?

Basically I have 2 product types,

Product type 1 ( which requires flat rate priority shipping )

Product type 2 ( which is standard economy shipping )

Is there any way to set something like this up?

I have installed a clone of the flat rate shipping which now shows the 2 shipping options but any way I can make these so that "product type 1" can only use the priority shipping ?

Sorry if this isn't very clear, any more information needed, please ask.

Regards

Jake

11 Jul 2011, 3:01 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping based on Product type?

What happens when Products from both Product Types are in the shopping cart? :unsure:

11 Jul 2011, 3:36 PM
#3
snowgoose avatar

snowgoose

New Zenner

Join Date:
Jul 2011
Posts:
21
Plugin Contributions:
0

Re: Shipping based on Product type?

Those products will hopefully be combined and use a third flat rate shipping amount which will be the cost of the Priority shipping and a little extra ( to cover any extra weight )

11 Jul 2011, 3:49 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping based on Product type?

These will check for what the products_type are in the cart ...

Let's assume you are testing for products_type 1 and 2 ...

Type 1 only in cart:

// bof: check products type for products_type 1 only
      if (!IS_ADMIN_FLAG) {
        global $cart;

        $chk_products_in_cart_type1 = 0;
        $chk_products_in_cart_type1 = $_SESSION['cart']->in_cart_check('products_type', '1');
        $full_count = $_SESSION['cart']->count_contents();

        if ($chk_products_in_cart_type1 > 0 && $full_count == $chk_products_in_cart_type1) {
          $this->enabled = true;
        } else {
          $this->enabled = false;
        }
      }
// eof: check products type for products_type 1 only

Type 2 only in cart:

// bof: check products type for products_type 2 only
      if (!IS_ADMIN_FLAG) {
        global $cart;

        $chk_products_in_cart_type2 = 0;
        $chk_products_in_cart_type2 = $_SESSION['cart']->in_cart_check('products_type', '2');
        $full_count = $_SESSION['cart']->count_contents();

        if ($chk_products_in_cart_type2 > 0 && $full_count == $chk_products_in_cart_type1) {
          $this->enabled = true;
        } else {
          $this->enabled = false;
        }
      }
// eof: check products type for products_type 2 only

Type 1 and 2 in the cart:

// bof: check products type for products_type 1 and products_type 2
      if (!IS_ADMIN_FLAG) {
        global $cart;

        $chk_products_in_cart_type1 = 0;
        $chk_products_in_cart_type2 = 0;
        $chk_products_in_cart_type1 = $_SESSION['cart']->in_cart_check('products_type', '1');
        $chk_products_in_cart_type2 = $_SESSION['cart']->in_cart_check('products_type', '2');
        $full_count = $_SESSION['cart']->count_contents();

        if ($chk_products_in_cart_type1 > 0 && $chk_products_in_cart_type2 > 0 ) {
          $this->enabled = true;
        } else {
          $this->enabled = false;
        }
      }
// eof: check products type for products_type 1 and products_type 2

To use them, let's say you were customizing flat.php, you would place the piece of code you need under the code:

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
      }
11 Jul 2011, 8:16 PM
#5
snowgoose avatar

snowgoose

New Zenner

Join Date:
Jul 2011
Posts:
21
Plugin Contributions:
0

Re: Shipping based on Product type?

Thanks very much for that Ajeh,

Just one quick Q,

Will I need to add another flat rate shipping module for both types of product in the basket?

11 Jul 2011, 10:11 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping based on Product type?

You should have 3 ... 1 for each of the separate Product type and 1 for the combined Product Types ...

12 Jul 2011, 12:14 AM
#7
snowgoose avatar

snowgoose

New Zenner

Join Date:
Jul 2011
Posts:
21
Plugin Contributions:
0

Re: Shipping based on Product type?

Ajeh:

You should have 3 ... 1 for each of the separate Product type and 1 for the combined Product Types ...
Ok Thanks,

I will get to work on this tomorrow.

Regards

Jake