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/...
Luke Holder's user avatar
  • 6,767
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 ...
Luke Pearce's user avatar
  • 3,863
6 votes
Accepted

How is Craft able to reuse fields in different Sections? (As opposed to EE.)

In Craft, all fields are stored in the craft_content table. They are otherwise independent of any field groups, layouts, sections, or anything else. PRO: This means that any element (Entry, Category, ...
Lindsey D's user avatar
  • 23.9k
4 votes

Unable to store Model in Commerce Order Fields

When you assign element IDs to a relation field you need to pass the data in an array format. See this related answer: In a plugin, how do I save an entry with a related entry Key information in ...
Luke Holder's user avatar
  • 6,767
4 votes

How do I set the value of a custom entries order field from a plugin?

I was close. I was correct in assuming my syntax was incorrect for setting the value of an entries field. Since an entries field is an array of elements, not just a single element, I just needed to ...
jthomas's user avatar
  • 373
4 votes
Accepted

Return entries where custom field partially contains

You could use the Preparse plugin to save the product ID part of your field in a new hidden field. Add a new "productId" Preparse field to your entry type with this code in the field's settings: {{ ...
carlcs's user avatar
  • 36.2k
4 votes
Accepted

How to pull out all user data in a template?

If i understand your question correct, you like to output the user data. I don't think that you need the getContent() function. But it's important, that you use the first() function. Here is your code:...
Tom Bauer's user avatar
  • 1,327
4 votes
Accepted

date in database -1 day as on frond-end

The database will be storing the date as seconds since 1970 (epoch) and your view on that is not localised. However, the front end date is localised for your time zone. Of this I am more sure than ...
Jeremy Daalder's user avatar
4 votes

How to save a new entry with custom fields - Craft 3

It turns out the data wasn't being saved as I hadn't set a fieldLayoutId value. Now that I've figured this out, I've written a helper method to make saving any entry type much easier: public static ...
SteveEdson's user avatar
4 votes
Accepted

Adding Columns to a table

With the supercool table maker you can create dynamic tables. Is this what you are looking for?
Robin Schambach's user avatar
3 votes

Get future multi-day event entries with custom date field

I think the simplest solution would be to make the eventEndDate field required even for single day events. Then you could do something like this: {% for event in craft.entries({ section:'events', ...
Alex Roper's user avatar
  • 2,622
3 votes
Accepted

Custom Field on Settings page

You can’t change or add fields to the General Settings page, but for site wide available content Craft has this concept of Globals. See the documentation on it: https://craftcms.com/docs/globals It’...
carlcs's user avatar
  • 36.2k
3 votes

Allow a dropdown custom field to be edit from a front end form

Just to make sure I am on the same page, you have a select field within the control panel that is populated with the prefix/title(s)? If that's the case, within your registration form, you could do ...
Damon's user avatar
  • 4,706
3 votes
Accepted

How to check custom field not empty within params?

You’re just missing the : at the end of :notempty: in your second example. This will work: {% set params = { section: 'sectionName', customField: ':notempty:', limit: 10} %}
Brandon Kelly's user avatar
3 votes
Accepted

More than one field for a fieldtype plugin

Nope – a single field can only have a single column in the craft_content table. If you need your FieldType to save complex data, you have two options: The easiest approach – by far – is to simply ...
Mats Mikkel Rummelhoff's user avatar
3 votes
Accepted

Checking value of customer order field within Plugin

What you're probably looking for is: if ($order->signupForNewsletter->contains('joinMailingList')) { echo "I've opted in"; } else { echo 'Not matched'; }
Brad Bell's user avatar
  • 67.2k
3 votes

Option and notes fields after cart at checkout for order, not just line items

First, add a custom field to your orders, let's call it orderNotes. Then, in any updateCart form, you can use an input with name="fields[orderNotes]" to set the value of that field. (Line items ...
Jeremy Daalder's user avatar
3 votes
Accepted

Add Checked Attribute to Custom User Fields on Frontend User Form

Solved! {% for letter in currentUser.newsletters.options %} <input type="checkbox" value="{{ letter.value }}" name="{{ letter.value }}" id="{{ letter.value }}" {% if letter.selected == ...
Chattervast's user avatar
3 votes

saving user field type custom field - Failed to set unsafe attribute

In order to set field values there is setFieldValue function $element->setFieldValue('fieldHandle', [Craft::$app->getUser()->getIdentity()->id]); All relation fields only accept the ...
Robin Schambach's user avatar
3 votes
Accepted

How to store custom data into a user

There are a whole bunch of ways to do what you want to do. You can add custom fields to user accounts. If you wanted to go with option 2 then you could create a custom text field and write the JSON ...
foamcow's user avatar
  • 2,019
3 votes
Accepted

Countries Field for Freeform

The answer: after you create a "select field", name it whatever you want - in this case country - and then add it to a form. Once you have done that, select that field within the form and ...
Roi Agneta's user avatar
  • 1,413
3 votes
Accepted

Get field settings of custom field via ElementInterface

I found the solution the values are stored in $this: public function normalizeValue($value, ElementInterface $element = null) { $type = $this->type; $shops = $this->shop; ... ...
antdev's user avatar
  • 83
3 votes
Accepted

Can I change a user field with twig without using a form?

Yes, it's possible via the special Twig do tag, which basically enables you to call methods without returning (i.e. outputting) anything (which is what happens with nearly every other Twig expression)....
Mats Mikkel Rummelhoff's user avatar
3 votes
Accepted

Add custom field value to Commerce Order Confirmation E-Mail

There are two ways of doing this: you can hook into the "live" product data using {{ item.purchasable.product.articleNumber }} -- and this is probably fine for the use-case of a confirmation ...
James Smith's user avatar
  • 4,924
2 votes

How to fetch entries based on contents of several custom fields?

No, but this is possible with a few lines of plugin code. You just need to create a DbCommand object from your criteria model and add your WHERE conditions with a OR operator. Add this function to ...
carlcs's user avatar
  • 36.2k
2 votes
Accepted

Failed to add a custom field in settings

You're getting that error message because your PHP environment is displaying PHP Strict mode error messages. By default, Craft will explicitly disable those if devMode is enabled (error_reporting(...
Brad Bell's user avatar
  • 67.2k
2 votes
Accepted

Custom fields on a structure or section archive page

What you could do is make a "Global" Which sets the header image. You could name the global something like "Event Page Fields" or something like that so its clear for your administrator where to look. ...
Justin Dekkers's user avatar
2 votes
Accepted

Filter products by custom boolean field

Found the answer. When creating the where clauses for the query, there's a line that checks empty($str), so passing a false boolean value, PHP interprets it as an empty string, so the where clause ...
karinegomes's user avatar
2 votes
Accepted

Option and notes fields after cart at checkout for order, not just line items

You could create a special product for the gift wrapping and offer to add it to the cart during the checkout process with a separate updateCart form. As for the notes, you can add a custom field to ...
foamcow's user avatar
  • 2,019
2 votes

Retrieve entries on custom field date using ElementCriteriaModel

The Error was because $criteria->inspectionDate > '("now")'; This way you can't get today's date. You could try this: $date = new DateTime(); $formattedDate = $date->format(DateTime::...
hashtagerrors's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible