2

How can I grab store's shipping country options in a template without a store tag? I would like to use them in a custom signup form.

2
  • Florian, did you get this to work (also with Store II)?
    – Nutmeg
    Jul 14 '14 at 20:15
  • Not really, I ended up doing something different. I believe I used a matrix with the values. And a little later the project got abandoned because of reasons outside of my control.
    – Florian
    Jul 14 '14 at 20:22
3

Store wont support that natively as far as I know but I'd personally look to use Stash to set a variable and then call it either elsewhere in that template or carry across to other templates.

Setting the variable is as pretty much as simple as {exp:stash:set} giving it a name and setting a few specific options, and then calling it with {exp:stash:get}. It's incredibly versatile.

Example:

{exp:store:checkout}
    ...

    {!-- Set the variable --}
    {exp:stash:set name="shipping_methods" save="yes"}{field:shipping_method}{/exp:stash:set}

    ...
{/exp:store:checkout}

{!-- Get the variable outside of the Store tags --}
{exp:stash:get name="shipping_methods"}

EDIT: Updated example to include save="yes" to demonstrate how to carry variable through to other template files.

9
  • Can you give a concrete example of how this would work? I cannot envision it.
    – Florian
    Mar 29 '13 at 11:54
  • Updated with example. The benefits of Stash will mean a second query isn't run within your templates and you can take advantage of caching and even pass that variable along to other templates.
    – Ian Young
    Mar 29 '13 at 20:26
  • As far as I can see this would not enable me to use the shipping countries in other templates, which is what I am trying to do.
    – Florian
    Apr 1 '13 at 9:23
  • 1
    As I said, you can carry it across to other templates if you wish to do so. You just need save="yes" to the Stash set tag (example updated). It's all in the Stash docs.
    – Ian Young
    Apr 1 '13 at 12:39
  • {field:shipping_methods} is probably not the tag you would want to use though as that would list the shipping gateways you have setup. You would want to use {field:shipping_country} and {field:shipping_region} Apr 1 '13 at 17:38
2

You can also use the Query Module to grab the available regions are.

<select>
{exp:query sql="SELECT * FROM exp_store_regions WHERE site_id = '1' GROUP BY country_code"}
<option value="{region_code}">
 {region_name}
</option>
{/exp:query}
</select>
4
  • That might work for regions, but not for countries. In exp_store_countries only the country codes are saved. Where does Store's {billing_country_options} get the country names?
    – Florian
    Mar 29 '13 at 11:30
  • The countries are generated from the countries.php file that comes with EE Mar 29 '13 at 11:32
  • Has anyone tinkered with Peter Lewis's plugin[1] for Store 1.6+ to make this compatible with V2+? [1]: devot-ee.com/add-ons/store-address-lists
    – Nutmeg
    Jul 14 '14 at 20:27
  • I have not personally but it should be pretty easy to do if you have an understanding of PHP. Jul 14 '14 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.