23
votes
Accepted
Why choose Craft Commerce over Magento
Obviously it's going to depend on each specific project, and I can only talk from my own (store owning) perspective, but over the years I have evaluated and installed and played with just about every ...
12
votes
Accepted
How can I update custom order fields in the frontend
Correct, you need to use fields[customFieldName] as the input name.
The following form should do it:
<form method="POST">
<input type="hidden" name="action" value="commerce/cart/...
11
votes
Accepted
Using Commerce to pay for posting entry
You will need to write a plugin with three responsibilities:
Keep track of which entries have been purchased
Set an entry to enabled when it has been purchased
Ensure that entries always have the ...
9
votes
Accepted
Craft Commerce: Detecting & Styling Flash Messages?
Getting a flash message also deletes it, so you should set it to a variable first, otherwise, when you try to access it a second time, it will be empty.
So you need to do something like this:
{% set ...
9
votes
Accepted
Commerce & PayPal - What does "Solution Type" mean?
Ignore the terminology, it really makes no sense. What it should say is this...
Require customers to use a PayPal account?
[Sole] No, a PayPal account is optional. Customers can still choose to pay ...
9
votes
Accepted
Structuring products variants
Usually when selling goods that come in different size and colors, a different SKU would exist for any size/color combination that you sell, thus a unique variant.
So, when that item becomes low in ...
8
votes
Accepted
Order Confirmation Email in Craft Commerce
To setup/debug email issues in commerce it's easiest to set up the simplest possible email and work your way up from there.
Check your Craft email settings - can you send & receive the test email
...
8
votes
Accepted
Craft Commerce: Dynamic Product Price
[** Updated Dec 2016]
I think at this stage the best approach will be plugin based.
Create a business logic plugin if you haven't already.
Two good ways of doing that are : Business Logic Plugin ...
8
votes
Accepted
Update Commerce Cart using Ajax
Yes, you can do all the normal commerce actions via ajax.
How this is done changed slightly with Craft 4/Commerce 4, so use the appropriate approach below. (Basically, they used to use an attribute ...
8
votes
Craft Commerce not sending E-Mails immediately
Thanks to @PhilipBoomy for his answer. The problem were missing cron jobs.
Additionally I want to add one more solution from the craft support team:
If you don't have the queue set up to run ...
7
votes
Accepted
3 for 2 etc with Craft Commerce
The documentation for adjusters is here:
https://craftcommerce.com/docs/adjusters
and
https://craftcommerce.com/docs/order-adjustment-model
Essentially your plugin creates a class that fulfils the ...
7
votes
Accepted
Ordering of products?
Product types are really all about data concerns - so if the data you're storing for your canines/equines (hereafter known as dogs and horses to save some typing ;) ) - is the same, then you're right ...
7
votes
Accepted
Check if an order has been refunded in a template?
You get the related transactions for an order with
order.transactions
So you can loop over the transactions like so:
{% for transaction in order.transactions %}
{{ transaction.type|title }}
{{ ...
7
votes
Accepted
One-Page Commerce Checkout
You won't be able to collect all information and take payment using one form/action. The customer information is added to the cart using commerce/cart/updateCart and payment is processed using ...
6
votes
Accepted
Display custom product field in cart
You could set a variable to access the products model like so:
{% set product = item.purchasable.product %}
and then access the fields like normal {{ product.myCustomField }}
The snapshot holds the ...
6
votes
Accepted
Craft Commerce: Displaying Individual Product Options in the Cart?
Answer is the example code for the cart:
{{ item.options.giftWrapped }}
6
votes
Craft Commerce: Detecting & Styling Flash Messages?
You can use hasFlash() instead, or pass false as a third argument, otherwise the flash message is discarded after the first time it is accessed.
{% if craft.session.getFlash('notice', null, false) %}
...
6
votes
Accepted
Craft Commerce: Sub total before tax in cart?
As of Commerce 1.1.1212, cart.itemSubtotalWithSale is deprecated.
Use {{ cart.itemSubtotal|currency(cart.currency) }} instead.
{{ cart.itemSubtotalWithSale|currency(cart.currency) }}
6
votes
Craft Commerce: Validation on Address Fields
In Craft3 you can do it like this:
use Craft;
use craft\base\Plugin;
use craft\commerce\models\Address;
use yii\base\Event;
class Custom extends Plugin
{
public function init()
{
...
6
votes
Accepted
Cart Items Total to include qty of variants
You can get the total quantity of items with:
cart.totalQty
Docs: https://craftcommerce.com/docs/order-model#totalqty
6
votes
Accepted
Transaction Error Message in Template
The error messages are returned to the template as flash messages.
Handling those is documented here:
https://craftcms.com/docs/templating/craft.session
One thing to watch out for is that flash ...
6
votes
Accepted
Setting Shipping Country and Method for the Cart screen
I agree with the basic underlying premise that showing full cost - i.e. with shipping - is essential on the cart index page for a modern checkout. Customers loathe what they see as a hidden surprise ...
6
votes
Accepted
How do I check if a product has stock in any of it's variants?
I managed do this with the following:
{% set variants = craft.commerce.variants({
product: product,
hasStock: true
}) %}
{% if variants|length <= 0 %}
Sold out
{% else %}
Add to ...
6
votes
Accepted
Changing base currency
Click on USD under Commerce->Settings->Payment Currencies and change the dropdown from USD to EUR. That will become Commerce's new base/primary currency.
If you also want to support USD, you can add ...
6
votes
Accepted
Custom status based on chosen payment gateway
Listen for the onBeforeOrderComplete event and do something like this (replacing values to match your setup).
craft()->on('commerce_orders.onBeforeOrderComplete', function($event){
$order = $...
6
votes
Accepted
Set Entries field in Commerce order on completion
See What is getContent() / the ContentModel, and how do I use it to get and set custom field values?
So you needed to change the method used for setting content on an element.
Also see In a plugin, ...
6
votes
How do you reset a cart under Craft Commerce 2?
Depending on context, here's another handy way of clearing the cart for Commerce 2/3
In a template, you can put:
{% do cart.setLineItems([]) %}
{% do craft.app.elements.saveElement(cart) %}
You ...
6
votes
Need somebody to help us with our existing Craft web page
Sorry to hear about your disappearing developer.
Stack Exchange as a Q&A site usually isn't the best place to find a developer, unless you'd like to post to Stack Overflow Jobs (https://...
6
votes
Accepted
Commerce: what is the purpose of a line item's snapshot?
The snapshot is there so that the key details of an order are forever more available on the order record.
Imagine living with Commerce for a long time - you will of course most likely add, change and/...
6
votes
Accepted
Get order shipping address in module
You can use the Addresses service to get the shipping address:
$address = craft\commerce\Plugin::getInstance()->getAddresses()->getAddressById($order->shippingAddressId);
This is the more ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
plugin-craftcommerce × 833plugin-development × 72
craft3 × 66
ecommerce × 50
plugin-craftcommerce2 × 40
templating × 36
order × 28
plugin-craftcommerce3 × 26
shipping × 25
plugins × 21
products × 20
discounts × 20
payment-methods × 19
adjusters × 16
categories × 13
stripe × 13
custom-field × 12
addresses × 12
emails × 11
ajax × 11
events × 11
payment × 10
users × 9
php × 9
tax × 9