Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Repeating Base Weights for Main Shipping Boxes

Repeating Base Weights for Main Shipping Boxes

Views: 3,569

Results 21 to 40 of 48
4 Mar 2013, 6:39 PM
#21
ajeh avatar

ajeh

Oba-san

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

Repeating Base Weights for Main Shipping Boxes

Try this instead:

// bof: add 6lbs per 4 items
global $cart;
$item_count = $_SESSION['cart']->count_contents();
[B]//$item_count = floor(($item_count/4));
$item_count = ceil(round( ($item_count/4), 1) );
[/B]$zc_tare_weight = $item_count * 6;
$zc_large_weight = $item_count * 6;
// eof: add 6lbs per 4 items

does that work better?

4 Mar 2013, 7:46 PM
#22
kclover avatar

kclover

New Zenner

Join Date:
Feb 2013
Posts:
26
Plugin Contributions:
0

Re: Repeating Base Weights for Main Shipping Boxes

It's perfect now, thanks! Down the road, when we do want to add spices and other products to our offerings, what would be the best way to keep these calculations going for the meat products but have separate ones for the "other" products? Some sort of split shipping modules/parameters by product category I take it?

4 Mar 2013, 8:31 PM
#23
ajeh avatar

ajeh

Oba-san

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

Re: Repeating Base Weights for Main Shipping Boxes

There would need to be a more complex method of calculating your Tare Rate as you cannot just count items, you have to check the Products themselves ...

This might be able to be done based on master_categories_id depending on how you setup your Products and Categories or you could make additional Product Types or some other method would need to be setup to identify your Meat Products from Other Products ... something like add a new field for:
product_is_meat

and when adding/editing Products then setting that field and use that to build the counts to work out the Tare Rates ...

You need to think out if you have Meat Products and Other Products or if you have more than just the two types of Product for building your Tare Rates ...

Once that is determined, then additional calculations can be made ...

NOTE: take into account what happens if the customer buys a Meat Product and 27 Other Products ... now you have the weights of both plus the various Tare Rates ... to get ideal shipping prices from UPS are you better off with a higher Maximum Weight?

If you add Spices or other kinds of Products, are you going to want to add USPS? FedEx?

4 Mar 2013, 9:58 PM
#24
kclover avatar

kclover

New Zenner

Join Date:
Feb 2013
Posts:
26
Plugin Contributions:
0

Re: Repeating Base Weights for Main Shipping Boxes

OK great thanks, not sure of all the particulars but good to know for when we get closer. I imagine we'll still only use UPS.

7 Nov 2013, 8:36 PM
#25
kclover avatar

kclover

New Zenner

Join Date:
Feb 2013
Posts:
26
Plugin Contributions:
0

Re: Repeating Base Weights for Main Shipping Boxes

Hi there, circling back to this discussion as we're now looking to add spices and sauces to our store. The code that you provided earlier in this thread helped us get to having the 6-pound refrigerated packaging reflected for our meat products (with an additional shipping box calculated after four+ meat products). But now that all products will no longer be meat, I need to figure out how to get it so the non-meat products get shipping calculated without the 6-pound add.

I imagine that customers will most often buy these products along with meat products, but I need to have it so that if they purchase, say, an 8-ounce jar of barbecue sauce by itself, that the shipping doesn't calculate as being 6.5 pounds. What would be the best route for this?

7 Nov 2013, 9:30 PM
#26
bislewl avatar

bislewl

Totally Zenned

Join Date:
Dec 2011
Location:
Wisconsin, USA
Posts:
674
Plugin Contributions:
12

Re: Repeating Base Weights for Main Shipping Boxes

There is a module out there that you can use called "shipping boxes manager", it allows you to calculate products based on the size and weight of the products, this is especially useful for dimensional shipping (where there is a large and light product). It's a free module from Numinix but it hasn't been added to the forum yet, I was told that will be happening very soon.

7 Nov 2013, 9:52 PM
#27
ajeh avatar

ajeh

Oba-san

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

Re: Repeating Base Weights for Main Shipping Boxes

There are two ways to approach this ...

You can try to use the master_categories_id to manage the count of Products in the cart that need this extra charge or what would be a safer method is to add a new field to the table:
products

such as:
product_is_meat

and then it does not matter about which Category the Products are that need the extra charge ...

While it does take more work to add the new field, it is a lot more reliable than trying to manage this via the master_categories_id to identify these Products that need the extra charge ...

7 Nov 2013, 10:24 PM
#28
kclover avatar

kclover

New Zenner

Join Date:
Feb 2013
Posts:
26
Plugin Contributions:
0

Re: Repeating Base Weights for Main Shipping Boxes

Thanks for the recommend bislewl, I'll have to look into that module.

Ajeh, of the two options you gave I'd say adding the product_is_meat field sounds best. I'm not seeing the location to do that in the admin interface, though, is that done through the Option Name and/or Value Manager or do I need to go into the actual database file and manually add a field?

Once I get that field added and put all the meat products under it, I imagine the code that you provided before/above would have to be reworked as right now it's coded to apply to all I believe. So what would the new coding be to make it an "if product_is_meat then add six pounds and max item count per box is 4"?

Thanks again!

8 Nov 2013, 2:10 AM
#29
ajeh avatar

ajeh

Oba-san

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

Re: Repeating Base Weights for Main Shipping Boxes

That requires custom coding to the Admin and then customizing the additional weight differently than before ...

I will try to look at this when I can but I am going to be pretty scarce for the next couple days so I am not sure when I can ...

9 Nov 2013, 12:09 AM
#30
kclover avatar

kclover

New Zenner

Join Date:
Feb 2013
Posts:
26
Plugin Contributions:
0

Re: Repeating Base Weights for Main Shipping Boxes

Thanks again. We're just looking to make the additions soon, so whenever you get a chance would be great!

10 Nov 2013, 2:32 AM
#31
ajeh avatar

ajeh

Oba-san

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

Re: Repeating Base Weights for Main Shipping Boxes

Okay ... so let's see if I wrote this right ...

1 To add your new field to the table:
products

Run this in the Tools ... Install SQL Patches ...

ALTER TABLE products ADD COLUMN product_is_meat tinyint(1) NOT NULL default '0';

2 Customize the file:
/your_admin/includes/modules/product/collect_info.php

around line 40:

                       'products_price_sorter' => '0',
                       'master_categories_id' => ''[B],
                 'product_is_meat'[/B]
                       );

around line 59 add:

                                      p.products_discount_type, p.products_discount_type_from,
                                      p.products_price_sorter, p.master_categories_id[B],
                         p.product_is_meat[/B]
                              from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
[/CODE

around line 158 add:
[CODE]
[B]// Product is Meat
    if (!isset($pInfo->product_is_meat)) $pInfo->product_is_meat = '0';
    switch ($pInfo->product_is_meat) {
      case '0': $in_product_is_meat = false; $out_product_is_meat = true; break;
      case '1': $in_product_is_meat = true; $out_product_is_meat = false; break;
      default: $in_product_is_meat = false; $out_product_is_meat = true;
    }
[/B]// set image overwrite

around 350 add:

[B]          <tr>
            <td class="main"><?php echo TEXT_PRODUCT_IS_MEAT; ?></td>
            <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_radio_field('product_is_meat', '1', $in_product_is_meat) . ' ' . TEXT_YES . '  ' . zen_draw_radio_field('product_is_meat', '0', $in_product_is_meat) . ' ' . TEXT_NO . ' ' . ($pInfo->product_is_meat == 1 ? '<span class="errorText">' . TEXT_PRODUCT_IS_MEAT_EDIT . '</span>' : ''); ?></td>
          </tr>
[/B]          <tr>
            <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>

3 Customize the file:
/your_admin/includes/modules/product/preview_info.php

and add the code around line 40:

      $product = $db->Execute("select p.products_id, pd.language_id, pd.products_name,
                                      pd.products_description, pd.products_url, p.products_quantity,
                                      p.products_model, p.products_image, p.products_price, p.products_virtual,
                                      p.products_weight, p.products_date_added, p.products_last_modified,
                                      p.products_date_available, p.products_status, p.manufacturers_id,
                                      p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
                                      p.product_is_free, p.product_is_call, p.products_quantity_mixed,
                                      p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max,
                              [B]p.product_is_meat,[/B]
                    p.products_sort_order
                               from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                               where p.products_id = pd.products_id
                               and p.products_id = '" . (int)$_GET['pID'] . "'");

4 Customize the file:
/your_admin/includes/modules/update_product.php

and add the code around line 50:

                            'products_discount_type_from' => zen_db_prepare_input($_POST['products_discount_type_from']),
                            'products_price_sorter' => zen_db_prepare_input($_POST['products_price_sorter'])[B],
                      'product_is_meat' => zen_db_prepare_input((int)$_POST['product_is_meat'])[/B]
                            );

5 Customize the code in:
/includes/classes/shipping.php

      $zc_large_weight= $za_large_array[1];

[B]// bof: add 6lbs per 4 items
global $cart;
$item_count = $_SESSION['cart']->in_cart_check('product_is_meat','1');
//$item_count = floor(($item_count/4));
$item_count = ceil(round( ($item_count/4), 1) );
$zc_tare_weight = $item_count * 6;
$zc_large_weight = $item_count * 6;
// eof: add 6lbs per 4 items
[/B]
      // SHIPPING_BOX_WEIGHT = tare

6 Create the new file:
/your_admin/includes/languages/english/extra_definitions/extra_meat_product.php

[B]<?php
define('TEXT_PRODUCT_IS_MEAT', 'Product is Meat');
define('TEXT_PRODUCT_IS_MEAT_EDIT', 'PRODUCT IS MEAT, EXTRA SHIPPING');[/B]

Be sure to backup everything before you make any of these changes ...

13 Nov 2013, 11:50 PM
#32
kclover avatar

kclover

New Zenner

Join Date:
Feb 2013
Posts:
26
Plugin Contributions:
0

Re: Repeating Base Weights for Main Shipping Boxes

Thanks, well it worked in getting the non-meat product to ship at its regular weight without the added 6 pounds. But when I went into the admin tool to make product edits as to what is and isn't meat, if I click on a product I get a blank page with "WARNING: An Error occurred, please refresh the page and try again." Thoughts on a fix for that?

13 Nov 2013, 11:56 PM
#33
ajeh avatar

ajeh

Oba-san

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

Re: Repeating Base Weights for Main Shipping Boxes

Check your debug logs and see what debug logs are indicating the problem is ...

14 Nov 2013, 12:26 AM
#34
kclover avatar

kclover

New Zenner

Join Date:
Feb 2013
Posts:
26
Plugin Contributions:
0

Re: Repeating Base Weights for Main Shipping Boxes

[13-Nov-2013 16:02:42] PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.product_is_meat
from products p, products_descrip' at line 14 :: select pd.products_name, pd.products_description, pd.products_url,
p.products_id, p.products_quantity, p.products_model,
p.products_image, p.products_price, p.products_virtual, p.products_weight,
p.products_date_added, p.products_last_modified,
date_format(p.products_date_available, '%Y-%m-%d') as
products_date_available, p.products_status, p.products_tax_class_id,
p.manufacturers_id,
p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
p.product_is_free, p.product_is_call, p.products_quantity_mixed,
p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max,
p.products_sort_order,
p.products_discount_type, p.products_discount_type_from,
p.products_price_sorter, p.master_categories_id
p.product_is_meat
from products p, products_description pd
where p.products_id = '123'
and p.products_id = pd.products_id
and pd.language_id = '1' in /public_html/includes/classes/db/mysql/query_factory.php on line 101

14 Nov 2013, 12:32 AM
#35
ajeh avatar

ajeh

Oba-san

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

Re: Repeating Base Weights for Main Shipping Boxes

Peek in phpMyAdmin and look at the structure of your table:
products

does it have a field for:
product_is_meat

15 Nov 2013, 7:12 PM
#36
kclover avatar

kclover

New Zenner

Join Date:
Feb 2013
Posts:
26
Plugin Contributions:
0

Re: Repeating Base Weights for Main Shipping Boxes

Well the person that set up the site never installed phpmyadmin, and I've spent a pretty good amount of time trying to install and configure it but just can't get to the point where I can succesfully log in. Any other methods or utilities for me to be able to view the table file and see if that field is in there?

15 Nov 2013, 7:18 PM
#37
ajeh avatar

ajeh

Oba-san

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

Re: Repeating Base Weights for Main Shipping Boxes

Do you have access to the Control Panel for the site? Usually there is a phpMyAdmin already setup for domains by the hosting provider ...

15 Nov 2013, 7:34 PM
#38
kclover avatar

kclover

New Zenner

Join Date:
Feb 2013
Posts:
26
Plugin Contributions:
0

Re: Repeating Base Weights for Main Shipping Boxes

I've only ever really accessed the ZenCart admin screen and any files directly over FTP. So I've never used cPanel or anything like that. When I first tried to browse to phpmyadmin for the site yesterday it didn't bring me to a login screen, so I obtained a phpmyadmin zip file and created a new phpmyadmin folder via FTP just under public_html. The login prompt came up when browsing after that, but I was never able to log in, even with all the user/db/host/pw info from our service provider.

15 Nov 2013, 7:51 PM
#39
ajeh avatar

ajeh

Oba-san

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

Re: Repeating Base Weights for Main Shipping Boxes

Let's try this ...

Go to Tools ... Install SQL Patches ... and run this line again:

ALTER TABLE products ADD COLUMN product_is_meat tinyint(1) NOT NULL default '0';

Either it adds it or you get an error message ...

15 Nov 2013, 7:55 PM
#40
kclover avatar

kclover

New Zenner

Join Date:
Feb 2013
Posts:
26
Plugin Contributions:
0

Re: Repeating Base Weights for Main Shipping Boxes

Failed: ERROR: Cannot ADD column product_is_meat because it already exists.

So looks like it's there at least!