New answers tagged

0

With the help of James Smith answer by suggesting Guzzle I was able to put the request together. I will post the working answer for future reference. use GuzzleHttp\Client as GuzzleClient; /** * Use Microsoft Azure Content Moderator API */ $client = new GuzzleClient([ 'base_uri' => 'https://uksouth.api.cognitive.microsoft.com/', 'http_errors' =...


2

Craft includes Guzzle which is very full-featured... I'd use that. Sorry I don't have time for converting your example but here's a simplified version of how to use it in a Craft plugin: $client = new \GuzzleHttp\Client([ 'base_uri' => 'https://www.example.com/api', 'http_errors' => false, 'timeout' => 10 ]); $data = ['some' => '...


0

Unfortunately, nothing I'm aware of for Craft 2, I'm afraid. In Craft 3, there's still not a great solution, but there is a $append parameter where you can kind of force it to go to the top of the list: https://github.com/yiisoft/yii2/blob/master/framework/base/Event.php#L103 But that would stop a plugin that was loaded after yours to use the same parameter ...


2

Probably best to just update the address business tax ID if it is in the wrong format automatically for them. Event::on(Order::class, Order::EVENT_BEFORE_SAVE, function(\craft\events\ModelEvent $event) { /** @var Order $order */ $order = $event->sender; if ($order->getShippingAddress() && $order->getShippingAddress()->...


1

What you are describing sounds a lot like the Position Fieldtype. I would look at that plugin for guidance.


1

I know, this is an old question, but it might help others in the future. You can add the method defineRules() to your element class, here is a sample from category element: * @inheritdoc */ protected function defineRules(): array { $rules = parent::defineRules(); $rules[] = [['groupId', 'newParentId'], 'number', 'integerOnly'...


Top 50 recent answers are included