Zen Cart Logo
Forums / Addon Shipping Modules / One shipping method not "checked"

One shipping method not "checked"

Locked

Views: 2,123

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
7 Nov 2010, 5:25 AM
#1
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

One shipping method not "checked"

Hi, we're doing some custom coding to the shipping modules on our test site, its all working fine, but I noticed that the radio button is never checked, even though only one shipping method is available.

Is there a way to enforce the radio button to 'checked' for the one shipping option?

ive had a brief look at; includes/modules/pages/checkout_shipping/header_php.php and inlcudes/classes/shipping.php but nothing is jumping out at me.

Thanks,

Scott.

7 Nov 2010, 5:32 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: One shipping method not "checked"

If there is ONLY one shipping module enabled, and that module only has one shipping option offered (only one "quote" prepared), then it is auto-selected by default. There will be no radio button because there's no need for one. In the default template this scenario will also say something like "there is only one shipping method available, as selected for you below".

7 Nov 2010, 6:16 AM
#3
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: One shipping method not "checked"

Hi, thats what i thought too.

I noticed the checkout shipping page said: "Please select the preferred shipping method to use on this order"

Even though there is only **one **shipping method available.

I suspect our code might be confusing things a bit, - Ill go back to the drawing board. :smile:

7 Nov 2010, 4:15 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: One shipping method not "checked"

What version of Zen Cart?

As DrByte indicated, in the current version, when there is 1 shipping module only, and that module only has one shipping option offered (only one "quote" prepared), and it is auto selected ... you see:

This is currently the only shipping method available to use on this order.

Does this happen in the Classic Template, if you test it?

8 Nov 2010, 1:33 PM
#5
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: One shipping method not "checked"

Hi Linda, i haven't had a chance to install that template, we're actually using the shipping module you suggested last week called; Zones Table Rate (for Multiple Zones)

There's something quirky going on as even when the checkout_shipping page says: “This is currently the only shipping method available to use on this order.”

The radio button is still not selected by default.

My programmer friend thinks an empty quote is being returned as one of the shipping methods, and changed this code in includes/classes/shipping.php from;

if (is_array($quotes)) $quotes_array[] = $quotes;

to:

if (is_array($quotes) && sizeof($quotes) > 0) $quotes_array[] = $quotes;

But thats not working either. :dontgetit

8 Nov 2010, 1:51 PM
#6
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: One shipping method not "checked"

I wanted to add that I cloned these shipping modules as I believe it was safe to do so?

So we have two files, e.g;

zonetablea.php and zonetableb.php

I hope thats not whats causing the problem.

8 Nov 2010, 2:01 PM
#7
ajeh avatar

ajeh

Oba-san

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

Re: One shipping method not "checked"

What are the settings for these two shipping modules that you see in the right side panel when you click on them in the Modules ... Shipping ...

8 Nov 2010, 2:24 PM
#8
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: One shipping method not "checked"

They're pretty standard, here is a copy and paste of the first file;

Set separate table rate for different shipping zones

Enable Table Method
True

Table Method
weight

Tax Class
--none--

Tax Basis
Billing

Sort Order
1

Shipping Zone 1
Toll Air next day service

Zone 1 Shipping Table
1000:7.45,3000:11.40,5000:18.20,10000:28.90,15000:36.00,20000:45.00

Zone 1 Handling Fee
0

Shipping Zone 2
--none--

Zone 2 Shipping Table
25:8.50,50:5.50,10000:0.00

Zone 2 Handling Fee
0

Shipping Zone 3
--none--

And the other;

Set separate table rate for different shipping zones

Enable Table Method
True

Table Method
weight

Tax Class
--none--

Tax Basis
Billing

Sort Order
2

Shipping Zone 1
Australia

Zone 1 Shipping Table
500:9.40,3000:12.70,5000:21.50,10000:28.90,15000:36.00,20000:45.00

Zone 1 Handling Fee
0

Shipping Zone 2
Shipping to Northern Territory

Zone 2 Shipping Table
500:9.40,3000:12.70,5000:21.50,10000:28.90,15000:36.00,20000:45.00

Zone 2 Handling Fee
0

Shipping Zone 3
--none--

The thing is, we added some custom code. The first file (zone toll) wont display if shipping to Northern Territory is selected (too expensive) or if dangerous goods are in the cart (this shipping method uses air) So we put;

if ($order->delivery['zone_id'] != 191)  // if not in Northern Territory Australia
		{
			if (!IS_ADMIN_FLAG && $_SESSION['cart']->in_cart_check('master_categories_id','34') > 0) $this->enabled = false; // dangerous goods - cant go by air
			if (!IS_ADMIN_FLAG && $_SESSION['cart']->in_cart_check('master_categories_id','35') > 0) $this->enabled = false; // dangerous goods - cant go by air
		}

The second file does two things - its the default shipping for Northern Territory and its also called in as the default shipping if dangerous goods are in the cart. We put in this file;

if ($order->delivery['zone_id'] != 191)  // if not in Northern Territory Australia
        {
            if ((!IS_ADMIN_FLAG && $_SESSION['cart']->in_cart_check('master_categories_id','34') == 0) && // dangerous goods - cant go by air AND
                (!IS_ADMIN_FLAG && $_SESSION['cart']->in_cart_check('master_categories_id','35') == 0))  // dangerous goods - cant go by air 
            {
                $this->enabled = false; // then disable this shipping module
            }
        }

Its pretty late here and my logic is fuzzy at best - Im trying to remember why I also defined Northern Territory as its own zone with its own shipping method.

Im sure I can code zone toll to only show if the selected state/territory in the Australia zone doesnt equal NT and doesnt contain dangerous goods.

Likewise, I need to hide the second Australia Post zonetable.php file as we want Toll to be the only shipping method available unless it encounters the two conditions just mentioned. :lookaroun

8 Nov 2010, 2:36 PM
#9
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: One shipping method not "checked"

please ignore this post.

15 Nov 2010, 1:03 AM
#10
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: One shipping method not "checked"

We ended up finding this same bug on the live website, if only one shipping option is available, the radio button is not checked.

We ended up putting; ```php
$checked = true;



Into the file; includes/templates/crush_zen/templates/tpl_checkout_shipping_default.php
15 Nov 2010, 9:35 AM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: One shipping method not "checked"

Scott_C:

We ended up finding this same bug on the live website, if only one shipping option is available, the radio button is not checked.

We ended up putting; ```php
$checked = true;

> 
> 
> Into the file; includes/templates/crush_zen/templates/tpl_checkout_shipping_default.php
Actually, if only one shipping option exists, then there IS no radio button TO check. 
At least, that's how all the built-in modules work anyway. Your addons may not be written to the same level as the ones that come with Zen Cart.
15 Nov 2010, 9:38 AM
#12
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: One shipping method not "checked"

Fair enough, I do recall you saying that. I've been cloning some of the add-on zone based shipping modules, perhaps this is a side-effect?