Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Hide Zone Shipping from Group

Hide Zone Shipping from Group

Views: 1,927

Results 1 to 15 of 15
15 Jan 2012, 2:27 AM
#1
lolwaut avatar

lolwaut

Zen Follower

Join Date:
Dec 2010
Posts:
142
Plugin Contributions:
0

Hide Zone Shipping from Group

Hi,

I am trying to hide Zone Shipping from a certain group. I have done this for another shipping module by entering this code:

// do not show to customers_group_pricing 32
      $chk_group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
      if ($chk_group_query->fields['customers_group_pricing'] == 32) {
        $this->enabled = false;
      }

I am pretty sure that the code will remain the same for the zone module; however, I don't know where in the file I should put the code... everywhere I have tried just breaks the shipping page and prevents it from loading.

Any help is appreciated.

Thanks!

15 Jan 2012, 4:48 AM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Hide Zone Shipping from Group

Put the code under:

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

But add to it, under the line:

// do not show to customers_group_pricing 32

the line:

global $db;
16 Jan 2012, 3:57 AM
#3
lolwaut avatar

lolwaut

Zen Follower

Join Date:
Dec 2010
Posts:
142
Plugin Contributions:
0

Re: Hide Zone Shipping from Group

excellent! worked like a charm. thanks so much!

16 Jan 2012, 3:58 AM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Hide Zone Shipping from Group

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

23 May 2012, 9:16 PM
#5
jaygee avatar

jaygee

New Zenner

Join Date:
Mar 2005
Location:
UK
Posts:
38
Plugin Contributions:
0

Re: Hide Zone Shipping from Group

Sorry to add to this thread but I'm trying to do something similar but rather than hiding from a Group I need to hide from a destination country. Reason is I have two zones shipping modules and want one to manage UK shipping and the other International. (Usual sledgehammer to crack a nut approach but there is method in my madness). Problem is they both appear all the time.

I need similar code to above but can't work out the expression to compare the country code. Simplified version is as follows:

// do not show to destination country UK
$value = expression to return 2 digit iso country code
if ($value <> UK) {
$this->enabled = false;
}

I have played around with $dest_country = $order->delivery['country']['iso_code_2']; but can't seem to get it working. If anyone can point me in the right direction it would be appreciated.

23 May 2012, 10:11 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Hide Zone Shipping from Group

What shipping modules are you trying to use for this?

23 May 2012, 10:25 PM
#7
jaygee avatar

jaygee

New Zenner

Join Date:
Mar 2005
Location:
UK
Posts:
38
Plugin Contributions:
0

Re: Hide Zone Shipping from Group

Thanks for your reply.

zones.php

I have a second one, zones2.php and I only want one to appear at a time. I've edited the language files differently for both hence the reason for using 2 rather than just increasing the number of zones.

23 May 2012, 10:32 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Hide Zone Shipping from Group

What are your settings on the Zone Rates zones shipping module in the right hand panel?

What are your settings on the Zone2 Rates zones2 shipping module in the right hand panel?

23 May 2012, 10:53 PM
#9
jaygee avatar

jaygee

New Zenner

Join Date:
Mar 2005
Location:
UK
Posts:
38
Plugin Contributions:
0

Re: Hide Zone Shipping from Group

zones - I have UK as zone 1
zones2 - I have ROW as zone 1 and EU as zone 2. I will add more zones later.

if someone in the UK goes to checkout zones displays correctly but zones2 also displays stating option not available
if someone from EU or ROW goes to checkout zones2 displays correctly but agan zones dispalys stating opion not available

I thought if I checked if UK or not in both I could disable one so not to confuse customer. More worrying I now seem to have lost both from Admin although they still work fine in the cart so may have screwed something in experimenting.

Thanks again for your interest.

23 May 2012, 11:11 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: Hide Zone Shipping from Group

The 2 character ISO code for United Kingdom is: GB ...

Set that on Zone 1 ... in Zone Rates zones ...

There is no EU ISO code, you need to list the 2 character ISO code of each country you want ...

The 2 character ISO Codes can be seen in the Locations / Taxes ... Countries ...

But before worrying about Zone2 Rates zones2 ... why do you think you need a separate shipping module file? Zone Rates zones has multiple Zones that you can setup ... by default that is 3 Zones ... if you need more Zones, you can customize it to add more ...

23 May 2012, 11:43 PM
#11
jaygee avatar

jaygee

New Zenner

Join Date:
Mar 2005
Location:
UK
Posts:
38
Plugin Contributions:
0

Re: Hide Zone Shipping from Group

All the country codes are set and I use UK as this incorporates Northern Ireland. In the past I have used just one zones module but decided to make some changes as I needed to incorporate more international zones following increases in UK postal charges.

I decided to use a second rather than just increase the number of zones as I wanted it so on checkout my UK customers have the shipping box heading set as "First Class Post" whereas my overseas customers see the box heading as "International Airmail". I can only achieve this by having 2 zones modules and changing the language filess accordingly.

I just don't want them both to display on the page at the same time with one simply saying it can't be used.

As I said, bit of a sledgehammer to crack a note but reading the above thread I assumed I could disable either appearing by simply checking on the country being despatched to being within the UK or outside.

Managed to get then back in admin now, ftp program was out of sync and put the language files in the wrong directory.

23 May 2012, 11:54 PM
#12
ajeh avatar

ajeh

Oba-san

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

Re: Hide Zone Shipping from Group

You have in your Locations / Taxes ... Countries ... a 2 character ISO code for UK? and EU? and something for ROW?

I am not sure how your countries table is setup for these as they do not exist by default and would have to be selected by the customer when their account is created ...

24 May 2012, 10:20 AM
#13
jaygee avatar

jaygee

New Zenner

Join Date:
Mar 2005
Location:
UK
Posts:
38
Plugin Contributions:
0

Re: Hide Zone Shipping from Group

Sorry, I am confusing you with the ISO codes. That is working fine, the EU and ROW was a generalisation. Within the tables I have the following for UK, EU and ROW:

Zones
UK – UK (I changed this from GB to UK in admin)

Zones2
EU - AT,BE,CY,CZ,DK,FI,FR,DE,GI,GR,HU,IS,IE,IT,LU,MT,MC,NL,NO,PL,PT,ES,SE,CH,TR
ROW - AF,AL,DZ,AS,AD,AO,AI,AQ,AG,AR,AM,AW,AU,AZ,BS,BH,BD,BB,BY,BZ,BJ………etc

The reason I want 2 zones modules is simply so I can set MODULE_SHIPPING_ZONES_TEXT_TITLE to different values so when UK customers check out they see a box heading of “Royal Mail First Class Post” and International customers “International Airmail”. It all works fine it’s just that both modules display with one stating that it cannot be used for the country depending on if delivery is within or outside the UK. Along the lines of the thread starter who wanted to hide the module for a customer group I wanted to do it for a country so in zones that deliver to my UK customers I would put an expression so it’s not called if the destination is not the UK and in the zones2 the expression would be it isn’t called if the destination is the UK. There doesn’t seem to be a facility in Admin to stop the module displaying if it doesn’t contain an option to deliver to the destination country unless I’ve missed it.

My understanding of the original thread is that by checking customer group is 32 prevented the module being used. I want to do the same but using the country code as the variable:

zones – only used if destination is UK.
zones2 – only used if destination is not the UK.

Hope this clarifies the situation and thank you for your input.

24 May 2012, 11:34 AM
#14
jaygee avatar

jaygee

New Zenner

Join Date:
Mar 2005
Location:
UK
Posts:
38
Plugin Contributions:
0

Re: Hide Zone Shipping from Group

Yes, as I'm sure you've worked out by now I'm a total idiot. How did I not see the box stating "skip countries". Why am I trying to hack the code when it all works how I want it in the first place. Apologies for wasting your time!!

24 May 2012, 12:58 PM
#15
ajeh avatar

ajeh

Oba-san

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

Re: Hide Zone Shipping from Group

Not a problem ... thanks for the update that you have found you can configure the Zone Rates shipping module as is without any changes to the code ... :smile: