Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Craft Commerce Workshop Peers 2016
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Luke Holder
April 13, 2017
Technology
0
51
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
Share
More Decks by Luke Holder
See All by Luke Holder
Update on Craft Commerce
lukeholder
0
70
Future of Craft Commerce
lukeholder
0
340
Other Decks in Technology
See All in Technology
AIと新時代を切り拓く。これからのSREとメルカリIBISの挑戦
0gm
0
1.2k
OpenShiftでllm-dを動かそう!
jpishikawa
0
110
変化するコーディングエージェントとの現実的な付き合い方 〜Cursor安定択説と、ツールに依存しない「資産」〜
empitsu
4
1.4k
AI駆動PjMの理想像 と現在地 -実践例を添えて-
masahiro_okamura
1
120
Greatest Disaster Hits in Web Performance
guaca
0
250
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
470
予期せぬコストの急増を障害のように扱う――「コスト版ポストモーテム」の導入とその後の改善
muziyoshiz
1
1.9k
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
10k
顧客との商談議事録をみんなで読んで顧客解像度を上げよう
shibayu36
0
240
AzureでのIaC - Bicep? Terraform? それ早く言ってよ会議
torumakabe
1
560
usermode linux without MMU - fosdem2026 kernel devroom
thehajime
0
230
SREじゃなかった僕らがenablingを通じて「SRE実践者」になるまでのリアル / SRE Kaigi 2026
aeonpeople
6
2.4k
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
Odyssey Design
rkendrick25
PRO
1
500
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
96
We Have a Design System, Now What?
morganepeng
54
8k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
Marketing to machines
jonoalderson
1
4.6k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
57
50k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
62
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
WCS-LA-2024
lcolladotor
0
450
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Transcript
None
None
None
None
Outline • Core concepts • Initial setup • Front-end build-out
• Write a plugin
Core Concepts
Elements • Products • Variants • Orders
Products • Think “Entry” (URL, post date, localizable)
• Think “Section” • Product URL format • Title format
• Automatic SKU? • Dimensions? • Multiple variants? • Field layout(s) Product Types
Laptop Manufacturer Model number Product Type Examples T-shirt Brand Graphic
Product type != taxonomy
Variants • Provides different versions of a single product
Variant Examples Laptop CPU Memory Screen size T-shirt Color Size
All products have at least one variant
Default Variant Default Variant Product A Product B Default Variant
Default Variant Default Variant
Variants • SKU • Price • Stock
Purchasables • Variants are a type of purchasable • All
purchasables define a unique SKU and a price
Purchasable Possibilities • Digital products • Events/tickets • Bookings •
Gift vouchers • Donations
Cart / Order • Carts become Orders when completed. •
Completed is currently triggered when paid or authorized in full.
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
Line Items • Belong to an Order • Populated by
a Purchasable. • Costs added and subtracted by adjustments.
Adjustments • Affect costs in cart during recalculation. Core Adjusters
• Shipping • Discounts • Tax
Transactions • Financial records on the order Types • Payment
• Authorize only • Refund
Order Statuses • Define a custom order processing workflow •
A default status is assigned when an order is first completed
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
Promotions • Sales • Discounts
Sales • Rules that affect a product’s price before it
is added to the cart
Discounts • Rules that affect a product’s price after it
has been added to the cart
Tax • Rules that affect taxes applied to the cart
Shipping • Rules that affect shipping costs applied to the
cart
Setup
General Setup
Order Fields Setup
Order Statuses Setup
Order Statuses Emails Setup
Order Status Emails Status Default Variant Default Variant Emails
Order Status Emails Status Default Variant Default Variant History Status
Tax Categories Setup
Payment Methods Setup
Product Types Setup
Tax Setup
Shipping Setup
Build
$ git clone http://github.com/lukeholder/peers
peers/style.css ➜ public peers/script.js ➜ public peers/_layout.html ➜ craft/templates/store
_layout.html
{% set cart = craft.commerce.cart %} Cart Once per page
but no penalty for multiple calls
{{ 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
_products.html
{% set products = craft.commerce.products %} {% for product in
products %} {% for variant in product.variants %} Products
{% set purchasable = product.defaultVariant %} {% set purchasable =
product.variant[0] ?? null %} Products
{% set products = craft.commerce.products({ type: 'clothing', hasVariant: { color:
'red' } }) %} Only returns products that have a red variant. Variants
{% set products = craft.commerce.products({ type: 'clothing', with: ['variants'] })
%} Eager Loading
{% set products = craft.commerce.products({ type: 'clothing', with: [‘variants',{ color:
'red' }] }) %} Only populates variants that are red. Eager Loading
index.html {% extends 'store/_layout' %} {% block body %} {%
include 'store/_products' %} {% endblock %}
<form method="post"> <input type="hidden" name="action" value="commerce/cart/updateCart"> <input type="hidden" name="redirect" value="store">
<form> Update Cart
Adding to cart Update Cart purchasableId qty note options
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
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=""/>
Updating Addresses Update Cart shippingAddressId or new shippingAddress billingAddressId or
new billingAddress sameAddress
{{ variant.salePrice|currency(cart.currency) }} {{ variant.price }} Price
None
_cart.html
Cart Line Items {% for item in cart.lineItems %}
Line Items item.subtotalWithSale Subtotal of line item item.total Total cost
of line item including adjustments
_index.html {% if cart.lineItems|length %} {% include "store/_cart" %} {%
endif %}
Update Line Item <input name="action" value="commerce/cart/updateLineItem"/> <input name="lineItemId" value="{{ item.id
}}"/> qty note options
Remove Line Item <input name="action" value="commerce/cart/removeLineItem"/> <input name="lineItemId" value="{{ item.id
}}"/>
None
Adjustments {% for adjustment in cart.adjustments %}
_info.html
_index.html {% if cart.lineItems|length %} {% include "store/_info" %} {%
endif %}
Email Email defaults to logged in users email
_payment.html
Plugin
craft/plugins/merch/MerchPlugin.php
Order Number Generation
Options Validation
Address Validation
Stock Notifier
Thank you @lukeholder