Zen Cart Logo
Forums / Basic Configuration / Disable product for some countries.

Disable product for some countries.

Views: 987

Results 1 to 5 of 5
29 Mar 2011, 3:51 PM
#1
xamber avatar

xamber

New Zenner

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

Disable product for some countries.

Hello i need major help with this. Please move this topic if i post in wrong place.

I've got a product that is now legal to sell in sweden but legal in all other countries. Can i disable so Swedish persons can't order just this particular product?

I also want to say that im a very green when it comes to coding so if you have a solution please explain it for me =)

30 Mar 2011, 2:43 PM
#2
xamber avatar

xamber

New Zenner

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

Re: Disable product for some countries.

bump (sorry this is urgent)

30 Mar 2011, 3:42 PM
#3
ajeh avatar

ajeh

Oba-san

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

Re: Disable product for some countries.

If you look at the function file:
/includes/functions/functions_general.php

and find the function zen_get_buy_now_button ...

you will see the code comments:

// 0 = normal shopping
// 1 = Login to shop
// 2 = Can browse but no prices

before the default code:

        default:
        // proceed normally
        break;

add the new case statements and change that to read:

// cannot be added to the cart
//do not show if not logged in
case ($_SESSION['customer_id'] < 1 && $product_id == 12):
return '<a href="' . zen_href_link(FILENAME_LOGIN, '', 'SSL') . '">' .  TEXT_LOGIN_TO_SHOP_BUTTON_REPLACE . '</a>';
break;
case ($_SESSION['customer_country_id'] == 204 && $product_id == 12):
return 'Invalid Switzerland';
break;

and can add the code:


// cannot be added to the cart
//do not show if not logged in
case ($_SESSION['customer_id'] < 1 && $product_id == 12):
return '<a href="' . zen_href_link(FILENAME_LOGIN, '', 'SSL') . '">' .  TEXT_LOGIN_TO_SHOP_BUTTON_REPLACE . '</a>';
break;
case ($_SESSION['customer_country_id'] == 204 && $product_id == 12):
return 'Invalid Switzerland';
break;

        default:
        // proceed normally
        break;

Now the customer has to be:
1 logged in to add products_id 12 to the cart

2 once logged in, they must NOT be from Switzerland

3 Apr 2011, 8:42 PM
#4
xamber avatar

xamber

New Zenner

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

Re: Disable product for some countries.

Can you please change the code for SWEDEN ? :D:P:smile:

Thanks!

4 Apr 2011, 1:09 PM
#5
ajeh avatar

ajeh

Oba-san

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

Re: Disable product for some countries.

If you look up the Country Switzerland, you will see that its countries_id is 204 ...

If you look up the Country Sweden, you will see that its countries_id is 203 ...

So, to adapt the code for another country the customer_country_id needs to be tested against that Country's countries_id ...