Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Craft Commerce Workshop Peers 2016

Craft Commerce Workshop Peers 2016

Workshop given on Craft Commerce 1.1 by Luke Holder at Peers conference 2016

Luke Holder

April 13, 2017
Tweet

More Decks by Luke Holder

Other Decks in Technology

Transcript

  1. • Think “Section” • Product URL format • Title format

    • Automatic SKU? • Dimensions? • Multiple variants? • Field layout(s) Product Types
  2. Purchasables • Variants are a type of purchasable • All

    purchasables define a unique SKU and a price
  3. Cart / Order • Carts become Orders when completed. •

    Completed is currently triggered when 
 paid or authorized in full.
  4. Orders Order Default Variant Default Variant Line Items Default Variant

    Default Variant Transactions Default Variant Default Variant History Default Variant Default Variant Adjustments Status Purchasable
  5. Line Items • Belong to an Order • Populated by

    a Purchasable. • Costs added and subtracted by adjustments.
  6. Order Statuses • Define a custom order processing workflow •

    A default status is assigned when an order is first completed
  7. Order History • Status changes are recorded in the order’s

    history, along with the reason for the change • Can optionally trigger an email to customer or administrator
  8. {{ craft.session.getFlash('notice') }} {{ craft.session.getFlash('error') }} {% for key, error

    in cart.allErrors %} <li>{{ error }}</li> {% endfor %} {% if cart.getErrors('email') %}email-error{% endif %} Notices & Errors
  9. {% set products = craft.commerce.products %} {% for product in

    products %} {% for variant in product.variants %} Products
  10. {% set products = craft.commerce.products({ type: 'clothing', hasVariant: { color:

    'red' } }) %} Only returns products that have a red variant. Variants
  11. {% set products = craft.commerce.products({ type: 'clothing', with: [‘variants',{ color:

    'red' }] }) %} Only populates variants that are red. Eager Loading
  12. index.html {% extends 'store/_layout' %} {% block body %} {%

    include 'store/_products' %} {% endblock %}
  13. Adding to cart <form method="post"> <input type="hidden" name="action" value="commerce/cart/updateCart"> <input

    type="hidden" name="redirect" value="store"> <input type="hidden" name="qty" value="1"> <input name=“purchasableId" value="{{ variant.purchasableId }}"> <form> Update Cart
  14. Options Update Cart <select name="options[giftWrapped]"> <option value="no">No gift wrap.</option> <option

    value="yes">Gift wrapped.</option> </select> Note <input name=“note" value=""/>