Forum

Thread tagged as: Shop

Do I need to "add page" to create a simple cart page?

This may be a funny question. But want to make sure if I MUST do "add page" to have cart and checkout pages?

sawan ruparel

sawan ruparel 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You just need to make sure the product is added, but you don't need to have a page to do that, and you don't even need to show the cart if you don't want to.

I am trying to get a typical product details page, I am having hard time displaying product options in pages/product.php page (I am not using template html file, because I have lot of customization that I need to do at php)

<perch:if exists="has_variants">
  <perch:input id="product" type="select" options="<perch:shop id="_variant_opts" type="hidden" />" placeholder="Please choose" required="true" /> 
</perch:if>

I am not sure how i will have add to cart form created too. :-(

Rachel Andrew

Rachel Andrew 394 points
Perch Support

To use Perch Template tags you have to use a Perch Template. You can't just put them into a PHP page.

Okay, I have now switched to an html template and I can see output for the options, however don't see radio box so found this in source

<perch:input id="options" name="opt-2[]" value="3" type="radio" required="required">
          pink/black
        </perch:input>

looks like perch:input is not being parsed?

Here is my code in html file

<perch:productopts>
  <fieldset>
    <legend><perch:productopt id="title" /></legend>
    <perch:productvalues>
      <perch:before><ul></perch:before>
      <li>
        <label>
          <perch:input id="options" name="opt-<perch:productvalue id="optionID" />[]" 
            value="<perch:productvalue id="valueID" />" type="radio" required="required" />
          <perch:productvalue id="valueTitle" />
        </label>
      </li>
      <perch:after></ul></perch:after>
    </perch:productvalues>
  </fieldset>
</perch:productopts>
<perch:input id="product" type="hidden" value="<perch:shop id="productID" type="hidden" />" />   
Drew McLellan

Drew McLellan 2638 points
Perch Support

Which page function are you using to display the form?

I don't know what was different, but I used below tag and I can see radio button for selection

<perch:if id="catalog_only" value="0">
  <perch:form id="add_to_cart" app="perch_shop" action="/cart">
    <perch:if exists="has_variants">
      <perch:productopts>
      <fieldset>
        <legend><perch:productopt id="title" /></legend>
        <perch:productvalues>
          <perch:before><ul></perch:before>
            <li>
              <label>
                <perch:input id="options" name="opt-<perch:productvalue id="optionID" />[]" 
                  value="<perch:productvalue id="valueID" />" type="radio" required="required" />
                <perch:productvalue id="valueTitle" />
              </label>
            </li>
          <perch:after></ul></perch:after>
        </perch:productvalues>
        </fieldset>
      </perch:productopts>
    </perch:if>
    <perch:input id="product" type="hidden" value="<perch:shop id="productID" type="hidden" env-autofill="false" />" />
    <perch:input type="submit" class="cart-submit" value="Add to Shopping Bag" />
  </perch:form>
<perch:else />
  <p>This item is available in-store only.</p>
</perch:if>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you saying that your issue is now resolved?

Yes sir. Now resolved