Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Smart Map working perfectly within Commerce. Meaning, I am able to show a map, etc. when I'm looking at products.

However, I am trying to build a "product locator" to find products in my area.

I am able to successfully pass the arguments to my results page - I can print out the zip code and distance that was chosen, but I am always getting into my "no results found" case.

{% set target = craft.request.getParam('near') %}
{% set radius = (craft.request.getParam('radius')) craft.request.getParam('radius') : 200 %}
    {% set params = {
    'target': target,
    'range': radius
} %}

{% set entries = craft.entries.address(params).order('distance').find() %}

radius is a drop-down of (miles) to choose from. near is the name of the text input the user enters the zip.

share|improve this question
up vote 2 down vote accepted

You need to tell Craft to look within the Commerce section like this:

{% set entries = craft.commerce.products.address(params).order('distance').find() %}
share|improve this answer
    
Great info, thanks Damon! – Lindsey D Jan 10 at 5:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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