Re: Checkout: Hide Country/Zone option for customers

238 views
Skip to first unread message

ashga

unread,
Sep 19, 2012, 4:36:50 AM9/19/12
to spree...@googlegroups.com
for states I did: -

    config.address_requires_state = false

in the config/initializers/spree.rb file not sure if there is a similar option for countries but I left countries in on mine and removed all except UK.



On Tuesday, September 18, 2012 2:07:19 PM UTC+1, silver-f wrote:
Hi Spree gurus, 

I have a store that will be launched in Norway, and in the first version I will only 
handle 1 payment option "Attached invoice". This means, no payment module needed for my Spree app.

My question is then; 

All my customers are going to be Norwegian, and I would like to disable the "Country" and "Zones" option and
leave this out from the checkout process. I guess one approach would be to set default values and hide the input fields.
Is this the way to go? Where should I start? 

Thank you very much




silver-f

unread,
Oct 1, 2012, 3:53:31 AM10/1/12
to spree...@googlegroups.com
Thanks ashga. 

I manange to remove the country fields for scountry (shipping) and bcountry (billig country) with Deface.
However, even though my default country is set, I still get 

"Country can not be blank" when proceeding with the checkout. (when country fields are hidden). 

How can I set the default country? Any ideas? 

Ash Ganatra

unread,
Oct 1, 2012, 3:58:08 AM10/1/12
to spree...@googlegroups.com
Not sure if this will work for you but I removed all the countries from my default tax zone (not sure if you used tax on your store)

so when I browse to /admin/zones/1/edit I only have the UK in the list.

Hope this helps!

-- 
Ash Ganatra
Sent with Sparrow

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spree-user/-/Ot1SVKXdLxkJ.
To post to this group, send email to spree...@googlegroups.com.
To unsubscribe from this group, send email to spree-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Ryan Bigg

unread,
Oct 2, 2012, 8:32:52 PM10/2/12
to spree...@googlegroups.com
I think this would be a useful thing to have within Spree. Please submit a pull request to fix it.

silver-f

unread,
Dec 29, 2012, 8:01:33 AM12/29/12
to spree...@googlegroups.com
Just fixed this with a one-liner:

1. Create a copy of _billing.html.erb and _shipping.html.erb into your Spree app to override it.
2. Remove the label and textfield in both files and replace with

 <%= bill_form.hidden_field :country_id, :value => "152" %>

Value here is hardcoded to id:152 which is Norway. You can find the other country ids in by searching
the countries.yml file in the Spree code.
Reply all
Reply to author
Forward
0 new messages