4

This is certainly still possible with Commerce 3 and Craft 3. In a custom plugin or module you can listen for the Transactions::EVENT_AFTER_CREATE_TRANSACTION event and amend the transaction amount at this point in the process. For example, you could make your own payment form that includes a partPaymentAmount field and posts to the normal commerce/payments/...


4

So you'll want to update the Super Table Block's content and to do that when in a Matrix field is a little tricky, but it can be done. $matrixBlocks = $entry->matrixField->all(); foreach ($matrixBlocks as $matrixBlock) { $superTableBlocks = $matrixBlock->superTableField->all(); foreach ($superTableBlocks as $superTableBlock) { $...


3

Generally speaking, no. Adjusters should always be computed from the current state of the order—the information required to match an Adjuster should be attached directly to an order. Your custom Adjuster is registered globally, then applied to Orders that match criteria you've defined in its adjust() method. That method returns an array of Adjustment models, ...


3

A simple-ish way you could do this is by using the pre-parse field to parse {{ entry.uid }}. This will then give you an extra column with the unique ID. You can then use Control panel JS to change that into a link/create a button. Something like: $(document).ready(function() { Craft.elementIndex.on('updateElements ', function(data){ if (data....


3

The error indicates that you're type-hinting the wrong class. Note this line in the error message: Argument 1 passed to amss\amss\AMSS::amss\amss{closure}() must be an instance of amss\amss\RegisterComponentTypesEvent, instance of craft\events\RegisterComponentTypesEvent given This comes from the type-hint in your function: function(...


3

You can use entry queries to fetch the entries and the elements service to save them. You can access the element service using Craft::$app->elements. Use Craft::$app->elements->saveElement($entry); to save an entry (or any other element). The best place to put business logic is a service class that you can then call from your controllers. So ...


3

I think my other answer is also part of this one. The only specifics I'd add here is that your action is getting "double-declared," in a way. Using the action param in a request has a lot of weight in Craft's eye—but you're stacking two strategies, and the system can't match it with your intent. My recommendation is (whenever possible) to use Craft'...


2

As per the docs at https://craftcms.com/docs/3.x/extend/element-types.html#saving-custom-field-values When saving values on a custom field, always use the setFieldValue() or setFieldValues() methods rather than directly accessing the field handle as a property on the element object. This ensures the value is normalized and marked as dirty for delta saves. $...


2

Since 3.4, you do this by passing an array of site ID/site-enabled mappings like so: $entry->enabledForSite = [1 => true, 2 => true]; Where 1 and 2 are your chosen site ids.


2

I had the same issue, turns out I had Craft Commerce Lite installed when the feature requires the Pro version.


2

In short, no. If this is config or data which are environment specific, they are as likely not good candidates for project config. Perhaps consider moving them to a table and access them through a Record/Model?


2

I've given up on this, from what I've looked at it's not going to be easy without a migration that creates the fields first (don't really want to do this for updatability issues). I've changed the scope of the plugin to be more bare-bones, and I think it's better for it.


2

I got help on Discord. The way to do it was Calendar::getInstance()->events->saveEvent($event); Edit: DateTime also needs to be replaced with Carbon()


2

I figured it out! Field-specific options need to go inside 'typesettings'. 'typesettings' => [ 'options' => [ ['label' => 'H1', 'value' => 'h1', 'default' => 1], ['label' => 'H2', 'value' => 'h2', 'default' => ''], ['label' => 'H3', 'value' => 'h3', 'default' => ''] ] ]


2

I experience the same with https://github.com/Saboteur777/craft-support forked from https://github.com/jasonmccallister/craft-support (which is a fork of https://github.com/lukeyouell/craft-support). Using composer update will not change "tracks" to the original plugin, so you are safe to update, the notification is a minor annoyance, though.


2

Try to disable the CSRF protection by event use Yii; use yii\base\ActionEvent; use yii\base\Event; use yii\web\Controller; Event::on(Controller::class, Controller::EVENT_BEFORE_ACTION, function (ActionEvent $actionEvent) { if ($actionEvent->action->id == 'update-cart') { Yii::$app->controller->enableCsrfValidation = false; } });


2

It should be $event->parsedValue - see here - https://github.com/craftcms/feed-me/blob/develop/src/services/Fields.php#L225


2

isValid should be set on the $event variable, not on $event->element: Event::on(Process::class, Process::EVENT_STEP_BEFORE_ELEMENT_SAVE, function (FeedProcessEvent $event) { $myField=$event->feedData['myfieldname']; if ($myField == null){ $event->isValid=false; } }); I haven't tested but looking at the feed-me source code, this ...


2

I've managed to get it working with great help from Brad Bell and Oli. The following code changes feedme slugs on Import. use craft\feedme\events\ElementEvent; use craft\helpers\ElementHelper; use craft\elements\Entry; Adding the following Event with the namespaces above works nicely. Event::on( Process::class, Process::...


2

The only feasible way of doing this without it being overwritten in each Craft update is by manipulating the elements using JavaScript. You can of course do this using your own module or plugin, but an easier approach would be to use the Control Panel JS plugin, which was created specifically to allow you to add JavaScript in the control panel.


2

You need to use the EVENT_REGISTER_CP_NAV_ITEMS event in the main plugin class. From the docs: use craft\events\RegisterCpNavItemsEvent; use craft\web\twig\variables\Cp; use yii\base\Event; public function init() { parent::init(); Event::on( Cp::class, Cp::EVENT_REGISTER_CP_NAV_ITEMS, function(RegisterCpNavItemsEvent $event) ...


2

Found it!!! Used ElementQuery::EVENT_AFTER_PREPARE


2

This might not be the answer you were looking for, but I don't think you need to go to great lengths trying to achieve something that in my opinion is not necessary. While it might seem to be not "clean" to have database table columns that are not required by your application/plugin, consider that todays ICT infrastructure is powerful enough to not ...


2

At the moment, your are overriding $event->linkOptions which contains an array with all options to an empty array with $event->linkOptions = []. First, add the below to your module and refresh any page on your site so you see what you are working with: Event::on( RedactorField::class, RedactorField::EVENT_REGISTER_LINK_OPTIONS, function(...


2

I figured it out. You have to create a separate block and it somehow figures out it's a child based on the level you specify. So something like this: [ 'new1' = [ 'modified' => 1, 'type' => 'parentBlock', 'enabled' => 1, 'collapsed' => 0, 'level' => 0, 'fields' => [ 'theme' =&...


2

First, from your field type’s inputHtml() method, make sure you’re passing the field instance to the template as a field variable, and the value as a value variable: protected function fieldHtml($value, ElementInterface $element = null): string { return Craft::$app->view->renderTemplate('plugin-handle/path/to/CustomField_input', [ 'field' =&...


2

For info I managed installing the plugin using composer php functions, here's the code : use Composer\Factory; use Composer\IO\BufferIO; use Composer\Installer; use Composer\Json\JsonFile; use Composer\Package\Locker; use Craft; $io = new BufferIO; $jsonPath = realpath(__DIR__ . '/../../../composer.json'); $lockPath = realpath(__DIR__ . '/../../../composer....


2

This looks like it’d be in a closure registered on the UrlManager::EVENT_REGISTER_CP_URL_RULES event, like this: Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES, function (RegisterUrlRulesEvent $e) { $e->rules['my/route'] => 'module/controller/action'; }); The above explains it almost in context—when ...


1

In the end the problem ended up being that I did not add the event listener to the input elements after the document was ready. The following code fires the eventHandler function correctly when any settings input field is changed, including colour inputs. $(document).ready(function () { $("form :input").change(eventHandler); });


1

If this is your plugin, you can register an AssetBundle with custom CSS and JS for your plugin. This will be loaded in your plugin settings page, and in your JS file you can then specify an event handler for your colour picker. You might need to add a specific class to the input in the settings template to ensure you can select it easily in your JS file. If ...


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