Forums / Built-in Shipping and Payment Modules / shipping tied to attribute

shipping tied to attribute

Views: 1,520

Results 1 to 18 of 18
8 Aug 2014, 2:30 PM
#1
andy_d avatar

andy_d

New Zenner

Join Date:
Aug 2014
Location:
Jersey City, NJ, USA
Posts:
4
Plugin Contributions:
0

shipping tied to attribute

I am trying to set up a shipping schema for artwork as follows:

one to seven prints: X dollars.
framed print: x dollars per framed print.

Is there any way I can tie this schema to the attributes?

Thank you.

12 Aug 2014, 5:34 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: shipping tied to attribute

What Shipping Module(s) are you currently using?

Are you wanting to just add to the shipping cost of your Shipping Module(s) based on the Attributes?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

14 Aug 2014, 10:01 PM
#3
andy_d avatar

andy_d

New Zenner

Join Date:
Aug 2014
Location:
Jersey City, NJ, USA
Posts:
4
Plugin Contributions:
0

Re: shipping tied to attribute

Ajeh:

What Shipping Module(s) are you currently using?

Are you wanting to just add to the shipping cost of your Shipping Module(s) based on the Attributes?

I am a true "newbie." Not sure which module I should select. Yes, I would. Thank you.

14 Aug 2014, 10:12 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: shipping tied to attribute

It depends on the shipping module you want to use such as UPS, USPS, FedEx or Zone Rates etc.

But something could be worked out to add additional charges to based on the Attributes ...

Now you need to decide how you want to price your shipping charges, then something could be worked into the code ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

15 Aug 2014, 2:13 PM
#5
andy_d avatar

andy_d

New Zenner

Join Date:
Aug 2014
Location:
Jersey City, NJ, USA
Posts:
4
Plugin Contributions:
0

Re: shipping tied to attribute

I figured the code angle would be the best. Where can I find the code for the shipping and product modules?
Thank you.

16 Aug 2014, 1:29 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: shipping tied to attribute

It would really be of help to know what shipping module(s) you want to use to manage your shipping ...

Are you wanting to use something like USPS? Or Flat rate? Or Item Rate?

Have you an URL to your site that we could perhaps peek at to get a feel for how your products are set up?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

18 Aug 2014, 2:28 PM
#7
andy_d avatar

andy_d

New Zenner

Join Date:
Aug 2014
Location:
Jersey City, NJ, USA
Posts:
4
Plugin Contributions:
0

Re: shipping tied to attribute

https://www.eldredboze.com/sales
Would like to use table for prints (up to 7 prints for $8, 8 to 14 for $16, etc.) and not sure what to use for the framed prints ($22 per framed print).
Again, thanks

18 Aug 2014, 2:51 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: shipping tied to attribute

So if I have:
7 prints and 1 Framed Print the cost would be $8.00 + $22.00 = $30.00
7 prints and 2 Framed Print the cost would be $8.00 + 2 x $22.00 = $52.00
7 prints and 3 Framed Print the cost would be $8.00 + 3 x $22.00 = $74.00

Correct?

And Frame Prints are always Options Name ID (options_id) 1 and Options Values ID (options_values_id) 1 correct?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

19 Aug 2014, 4:17 PM
#9
ajeh avatar

ajeh

Oba-san

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

Re: shipping tied to attribute

If this is what you are wanting, you could add the code in **RED **to the bottom of the file:
/includes/classes/shopping_cart.php

     return $new_qty;
  }
[B]// bof: change $total_count for options_id/options_values_id combo
/**
 * calculate the number of items in a cart based on an attribute option_id and option_values_id combo
 * USAGE:  $chk_attrib_1_16 = $this->in_cart_check_attrib_quantity(1, 16);
 * USAGE:  $chk_attrib_1_16 = $_SESSION['cart']->in_cart_check_attrib_quantity(1, 16);
 *
 * @param float $check_qty
 * @param int $check_option_id
 * @param int $check_option_values_id
 * @param string $message
 */
  function in_cart_check_attrib_quantity($check_option_id, $check_option_values_id) {
    // if nothing is in cart return 0
    if (!is_array($this->contents)) return 0;

    // compute total quantity for match
    $in_cart_check_qty = 0;
    // get products in cart to check
    $chk_products = $this->get_products();
    for ($i=0, $n=sizeof($chk_products); $i<$n; $i++) {
      if (is_array($chk_products[$i]['attributes'])) {
        foreach ($chk_products[$i]['attributes'] as $option => $value) {
          if ($option == $check_option_id && $value == $check_option_values_id) {
  //          echo 'Attribute FOUND FOR $option: ' . $option . ' $value: ' . $value . ' quantity: ' . $chk_products[$i]['quantity'] . '<br><br>';
            $in_cart_check_qty += $chk_products[$i]['quantity'];
          }
        }
      }
    }
    return $in_cart_check_qty;
  }
// eof: change $total_count for options_id/options_values_id combo
[/B]}

Then customize your file:
/includes/modules/shipping/table.php

with the code in RED:

  function quote($method = '') {
    global $order, $shipping_weight, $shipping_num_boxes, $total_count;

[B]// bof: change $total_count for options_id/options_values_id combo
    $chk_options_id = 20;
    $chk_options_values_id = 72;
    $additional_shipping = 22.00;
    $reduce_count = $_SESSION['cart']->in_cart_check_attrib_quantity($chk_options_id, $chk_options_values_id);
    $total_count = $total_count - $reduce_count;
// eof: change $total_count for options_id/options_values_id combo
[/B]
    // shipping adjustment
    switch (MODULE_SHIPPING_TABLE_MODE) {
[B]// bof: change $total_count for options_id/options_values_id combo
    $additional_shipping_charge = $reduce_count * $additional_shipping;
[/B]
    $this->quotes = array('id' => $this->code,
    'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE . $show_box_weight,
    'methods' => array(array('id' => $this->code,
    'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
    'cost' => $shipping[B] + $additional_shipping_charge [/B]+ (MODULE_SHIPPING_TABLE_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_TABLE_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_TABLE_HANDLING) ) ));
[B]// eof: change $total_count for options_id/options_values_id combo
[/B]
    if ($this->tax_class > 0) {

And this will now charge the count for Products based on the number of regular Products that are Prints using the Table Rate table settings and for the Framed Prints it will charge $22.00 each ...

NOTE: change the values on:

[B]    $chk_options_id = 20;
    $chk_options_values_id = 72;
[/B]

To match your options_id value and the options_values_id value ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Jan 2015, 8:47 AM
#10
raunharman avatar

raunharman

Zen Follower

Join Date:
Dec 2005
Posts:
165
Plugin Contributions:
0

Re: shipping tied to attribute

I have a similar query.

I am using Zen version 1.3.9 with Books module.
The shipping module is Flat Rate.
I want to offer free shipping on the entire order when a particular attribute is selected.
Could you please help.
Thanks in advance.

http://www.raunharman.com
http://www.raunharman.net
Website Development, E-Book Solutions & Handicraft Exports

4 Jan 2015, 2:19 PM
#11
ajeh avatar

ajeh

Oba-san

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

Re: shipping tied to attribute

Do you have an example of an URL to the Product and which Attribute you want checked that if in the shopping cart you want to give Free Shipping?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Jan 2015, 3:19 PM
#12
raunharman avatar

raunharman

Zen Follower

Join Date:
Dec 2005
Posts:
165
Plugin Contributions:
0

Re: shipping tied to attribute

Yes, sure.
http://asiabookzone.com/index.php?main_page=product_info&cPath=168_169&products_id=6423

I want that if the customer buys Notebooks and Registers (2nd attribute), he should be entitled to free shipping on the entire order.

Thanks for your prompt response.

http://www.raunharman.com
http://www.raunharman.net
Website Development, E-Book Solutions & Handicraft Exports

4 Jan 2015, 3:59 PM
#13
ajeh avatar

ajeh

Oba-san

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

Re: shipping tied to attribute

Install the shipping module for Free Shipping Options freeoptions ...

Add the code from post #9 for the file:
/includes/classes/shopping_cart.php

then on the Flat Rate flat shipping file, add the code in RED:
/includes/modules/shipping/flat.php

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
      }

[B]// bof: Free Shipping Test - do not show Flat if Product with Attribute is in cart
if (!IS_ADMIN_FLAG) {
  $chk_cart = $_SESSION['cart']->in_cart_check_attrib_quantity(20, 70);
echo 'flat: ' . $chk_cart . '<br>';
  if ($chk_cart > 0) {
    $this->enabled = false;
  }
}
// eof: Free Shipping Test
[/B]
      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) {

and in the file for Free Shipping Options freeoptions add the code in RED:
/includes/modules/shipping/freeoptions.php

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_FREEOPTIONS_STATUS == 'True') ? true : false);
      }
[B]
// bof: Free Shipping Test - do not show FREEOPTIONS unless Product with Attribute is in cart
if (!IS_ADMIN_FLAG) {
  $chk_cart = $_SESSION['cart']->in_cart_check_attrib_quantity(20, 70);
echo 'freeoptions: ' . $chk_cart . '<br>';
  if ($chk_cart < 1) {
    $this->enabled = false;
  }
}
// eof: Free Shipping Test
[/B]
      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FREEOPTIONS_ZONE > 0) ) {

Change the values of 20, 70 to match your option name id and option value id, I believe those will be 3,5 to match As prescribed by School ( +Rs.650.00 ) ...

This should now turn on/off Flat Rate flat and on/off Free Shipping Options based on if the Attribute is in the cart ...

NOTE: comment out the two echos, once you have this working right ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

5 Jan 2015, 7:23 AM
#14
raunharman avatar

raunharman

Zen Follower

Join Date:
Dec 2005
Posts:
165
Plugin Contributions:
0

Re: shipping tied to attribute

Thanks for your prompt reply.

However, when I am ordering without the attribute (notebooks and registers --not required), the order is processing fine.

But when I select the attribute (Notebooks and Registers - As prescribed by School), it shows the following message:

Not Available At This Time
Sorry, we are not shipping to your region at this time.
Please contact us for alternate arrangements.

Further, in the top left hand corner of the page, the following text appears: flat: 1
freeoptions: 1

Have I done something wrong?

http://www.raunharman.com
http://www.raunharman.net
Website Development, E-Book Solutions & Handicraft Exports

5 Jan 2015, 1:31 PM
#15
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,111
Plugin Contributions:
56

Re: shipping tied to attribute

Do you have the **freeoptions **shipping module enabled? If not, that's your issue.

5 Jan 2015, 2:07 PM
#16
ajeh avatar

ajeh

Oba-san

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

Re: shipping tied to attribute

First, make sure Free Shipping Options is installed as lat9 pointed out ...

Next, when done testing, you need to comment out the two echo lines to not see that:

[B]//[/B]echo 'flat: ' . $chk_cart . '<br>';
[B]//[/B]echo 'freeoptions: ' . $chk_cart . '<br>';

Those echos are there for testing to ensure the new function is working in both shipping modules ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Jan 2015, 6:29 AM
#17
raunharman avatar

raunharman

Zen Follower

Join Date:
Dec 2005
Posts:
165
Plugin Contributions:
0

Re: shipping tied to attribute

Thanks a lot.

It worked well.

I had installed the Free Shipping Options module, but had removed the Total>=0.

Thanks again for your help.

http://www.raunharman.com
http://www.raunharman.net
Website Development, E-Book Solutions & Handicraft Exports

6 Jan 2015, 2:29 PM
#18
ajeh avatar

ajeh

Oba-san

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

Re: shipping tied to attribute

Thanks for the update that this was able to work for you ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!