Shipping Problem

Results 1 to 20 of 44
13 Dec 2011, 17:25
#1
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Posts:
1,230
Plugin Contributions:
2

Shipping Problem

I hope someone can answer this.

I am using table rate shipping when adding products to the shopping cart. I have two tables, one set up for First Class Post and one set up for Royal Mail Track and Trace. For most products it is ok to show both shipping options, however we have just discovered that certain items require special insurance as they are flammable products. The insurance has already been added onto the prices of these products so not a problem there and it doesn't affect the shipping price. But on items where insurance has been applied to the price I need to be able to display Royal Mail Track and Trace only as a shipping option. All other products will display both First Class Post and Royal Mail Track and Trace, it is only the flammable items where I need to disable the First Class Post. So how would I go about doing this?

I have seen similar posts but none of them really fit.

This one is close

http://www.zen-cart.com/forum/showthread.php?t=175429


But ideally I would like to be able to control it from the admin as not all products are listed yet so I don't know what the product ID's or Category ID's will be for each flammable product so I don't know which one's need to have First Class Post Disabled on.
14 Dec 2011, 19:07
#2
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Problem

You could use something like this code, for example say you were customizing the:
/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);
      }

// bof: skip certain products_id and disable they are in the cart
      if (IS_ADMIN_FLAG == false) {
        global $cart;
        $chk_skip_products = 0;
        $chk_skip_products += $_SESSION['cart']->in_cart_check('products_id','1');
        $chk_skip_products += $_SESSION['cart']->in_cart_check('products_id','38');
        $chk_skip_products += $_SESSION['cart']->in_cart_check('products_id','39');
        if ($chk_skip_products > 0) {
          $this->enabled = false;
        }
      }
// eof: skip certain products_id and disable they are in the cart


You can add more or less products_id by copying the pattern ...
14 Dec 2011, 19:40
#3
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Posts:
1,230
Plugin Contributions:
2

Re: Shipping Problem

Thanks Linda, could this be developed to work from the admin?

So that instead of hard coding we could choose the postage type from something like a dropdown menu?
14 Dec 2011, 19:51
#4
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Problem

Yes ... this could be written to add a new field such as:
products_shipping

and then that could be tested for the value to see how many are in the cart of a given value to then be used to control the shipping modules ...

All you have to do is add the new field to the products table and then customize the code in the Admin to access that field to aa/edit etc. and then customize the shipping modules to test for it ...

Easy smeazy, eh? :cool:
14 Dec 2011, 20:07
#5
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Posts:
1,230
Plugin Contributions:
2

Re: Shipping Problem

:unsure:

Er yes I guess so, but how would I write the code to do this? I know the zen code but will be honest and say I'd struggle on this to write from scratch. But could do this as a Mod for other users if I could get it to work with your help?
15 Dec 2011, 12:57
#6
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Posts:
1,230
Plugin Contributions:
2

Re: Shipping Problem

Hi Linda, how would I go about writing the code to connect this up to the admin, what files would I need to edit and do you have any idea of the code I would need to do this?

Thank You

Nick
15 Dec 2011, 14:48
#7
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Problem

I would have to write the whole set of code to be able to tell you everything from adding the new field to using it in the shipping modules as the test ...

For adding a new field, find one such as the field:
product_is_always_free_shipping

and trace its use in the Admin with the Tools ... Developers Tool Kit ... to see how it is used for all of the modules on a Product for adding/editing ...
15 Dec 2011, 16:46
#8
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Posts:
1,230
Plugin Contributions:
2

Re: Shipping Problem

ok, not sure I have time to develop something like that at the moment. But been having a think about a way to do this quick and easy.

If I had a category with two sub categories like this

Chemicals > Flammable

Chemicals > Non Flammable

Could I use the code you gave me earlier in this thread to assign the correct postage to the correct category > sub category?

Nick
15 Dec 2011, 16:54
#9
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Problem

You can test the cart based on either products_id or based on master_categories_id in an easy manner ...

Do the Products in the Flammable Category all use that categories_id as their master_categories_id value?
15 Dec 2011, 17:15
#10
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Posts:
1,230
Plugin Contributions:
2

Re: Shipping Problem

That would be correct, the categories would be broken down like this:

Chemicals (master category) > Flammable (sub category)

Chemicals > Non Flammable

Controllers (master category) > Flammable (sub category)

Controllers > Non Flammable

Dosing Systems (master category) > Flammable (sub category)

Dosing Systems > Non Flammable

Pumps (master category) > Flammable (sub category)

Pumps > Non Flammable

Tanks, Bunds and Accessories (master category) > Flammable (sub category)

Tanks, Bunds and Accessories > Flammable

Water Testing (master category) > Flammable (sub category)

Water Testing > Non Flammable

General Spares (master category) > Flammable (sub category)

General Spares > Non Flammable

Safety Equipment (master category) > Flammable (sub category)

Safety Equipment > Non Flammable


So in effect the sub category would be the master category for those products beneath the top level master category if that makes sense.


Non-Flammable would be first class post

Flammable would be Royal Mail Track and Trace

This is the website http://www.jakwater.co.uk for reference bearing in mind I haven't made up the above sub categories yet.

Something else, if a customer comes along and purchases a product that is Non flammable and then another item that is flammable then the cart would need to be intelligent enough to realise that the non flammable product would go at the flammable postage rate which would be royal mail track and trace.
15 Dec 2011, 17:22
#11
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Problem

Then you could use the code:
// bof: skip certain categories and disable they are in the cart for master_categories_id 7, 10 and 14
      if (IS_ADMIN_FLAG == false) {
        global $cart;
        $chk_skip_categories = 0;
        $chk_skip_categories += $_SESSION['cart']->in_cart_check('master_categories_id','7');
        $chk_skip_categories += $_SESSION['cart']->in_cart_check('master_categories_id','10');
        $chk_skip_categories += $_SESSION['cart']->in_cart_check('master_categories_id','14');
        if ($chk_skip_categories > 0) {
          $this->enabled = false;
        }
      }
// eof: skip certain categories and disable they are in the cart for master_categories_id 7, 10 and 14
15 Dec 2011, 17:27
#12
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Posts:
1,230
Plugin Contributions:
2

Re: Shipping Problem

So would that be intelligent enough to realise that if a customer comes along and purchases a product that is Non flammable (first class) and then another item that is flammable (royal mail track and trace) to charge the flammable postage rate which would be royal mail track and trace and calculate the price on weight according to the flammable postage rate.
15 Dec 2011, 17:32
#13
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Problem

No that would be intelligent enough to know that flammable products are in the cart, if you are testing the master_categories_id of the flammable products ...

Then, you need to decided that based on the results of are there any flammable products in the cart, should the shipping module be active or inactive by the setting of the $this->enabled ...

So if you add that code to the shipping module that should NOT run when flammable products are in the cart, then it will turn off that shipping module if a flammable product is added to the cart so it will not show as a shipping choice ... now, that would leave the other shipping module active as the only choice ...
15 Dec 2011, 17:36
#14
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Posts:
1,230
Plugin Contributions:
2

Re: Shipping Problem

right so based on your code, then I don't have to do anything other than assign the categories to the code? right?
15 Dec 2011, 17:38
#15
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Problem

Correct ... and if you need more categories to be checked then you can just add more lines of:
        $chk_skip_categories += $_SESSION['cart']->in_cart_check('master_categories_id','7');


where you set the 7 to the flammable categories_id ... which is the master_categories_id ... to be checked if Products from it are in the cart ...
15 Dec 2011, 17:44
#16
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Posts:
1,230
Plugin Contributions:
2

Re: Shipping Problem

ok I think that could be a solution then. will do some testing :-)

Thanks for your time and patience Linda.
15 Dec 2011, 17:47
#17
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Posts:
1,230
Plugin Contributions:
2

Re: Shipping Problem

Just one more thing Linda, and sorry for being dim. What file would I put this code in?
15 Dec 2011, 17:56
#18
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Problem

You have two shipping modules ... one of them you do not want when there are flammable products ... which shipping module is that? :unsure:
15 Dec 2011, 17:58
#19
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Posts:
1,230
Plugin Contributions:
2

Re: Shipping Problem

Just thought I'd add that I'm using table rates and there's two separate files set up called table1.php (first class) and table2.php (royal mail track and trace)

Would I add the code into both of these files?
15 Dec 2011, 18:01
#20
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Problem

Do you want them BOTH to not work?

Or are you trying to turn off 1 of these two files?

Or, are you trying to turn ON a 3 shipping module and turn OFF these two shipping modules? :unsure: