Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [plugin-development]

Questions having to do with constructing plugins.

0
votes
0answers
6 views

Is it possible to use craft()->runController with variables in Craft 2

I'm trying to run a plugin 1 controller from plugin 2. I can get it to run and re-direct to plugin 1's controller but as it is not being run with posted variables I need to be able to tell plugin 2's ...
0
votes
0answers
16 views

How do I correctly send an external request to a module controller? runAction() is returning null

Craft 3.1.18 I have a simple controller VeteransController made using the updated Business Logic module. The purpose of this controller is to create a very simple endpoint for an external Vue ...
0
votes
1answer
14 views

How to cache a Guzzle Http request?

In my module I have the following: $client = new Client(['base_uri' => myBaseUri]); $response = $client->request('GET', myQueryString, [ 'headers' => [ 'Accept' ...
1
vote
1answer
21 views

How to edit a date field in a plugin

So I want to edit date type filed on entry save, but I don't know how to format it. It times out on string and don't seem to accept DateTime objects either. Event::on( Elements::class, ...
3
votes
2answers
25 views

How do you save a new Entry to be enabled on 2+ Sites?

I've made a plugin that let's you import Entries from a CSV file and I'm working through adding localization (Sites) support to it, but I can't figure out the right way to enable an Entry for a second ...
1
vote
1answer
24 views

Custom Plugin for ZenDesk Tickets

I need all of the custom fields on an order submitted to ZenDesk to create a new ticket once the order is completed. Once a ticket is created in ZenDesk, we will need the ticket number saved on a new ...
1
vote
1answer
18 views

Craft 3 Controller - Redirect with errors

I cant get this to work. I'm doing a post to a controller action. From that action I'm doing a lot of validations, db insert, file uploads etc. Coming from Laravel Im used to is doing like this: (...
2
votes
0answers
20 views

Creating multiple plan subscriptions

Versions: - Craft CMS (3.1.21) - Craft Commerce (2.1.2) - Stripe for Craft Commerce (1.2.0) Problem: - My website offers user's ability to subscribe to several subscriptions at the same time. ...
1
vote
0answers
34 views

What's the most performant way to get reverse related entries within an Element Query?

What's the most performant way to get reverse related entries within an Element Query? Here's a contrived example of this. I have thousands of "book" entries and thousands of "collection" entries. I ...
1
vote
1answer
15 views

Get HTML of rendered template inside module

I'm getting started with plugin/module development. I want to get the template file, pass some variables to it, and get rendered HTML of that template into a string variable. How do I do that?
-1
votes
0answers
25 views

Returning A Plugin Date Setting

So I'm diving into Plugin development with Craft. Loving it so far, it's so easy to get started! But, I can't find any documentation on standard returning/initialization for all the different field ...
1
vote
0answers
30 views

Custom plugin: Creating new fields will delete the field group they're being created in

I have a simple plugin which reads in a CSV file, and based on the first row of data will create a new field group, and then create fields within that group. The first time I run it everything goes ...
1
vote
1answer
16 views

Possible to reflect changes to a plugin's composer.json without uninstall/reinstall?

When working on a plugin recently, I decided to add a CP section: composer.json { ... "extra": ... "hasCpSection": true ... } The only way that I was able to have this ...
1
vote
1answer
16 views

My plugin settings page is never loaded

I have been staring at this all morning, comparing to other plugins online and cannot see why my plugin settings page never registers. I have verified the actual settings model is populated, but ...
1
vote
1answer
27 views

Updating private repo plugins from admin?

Is it possible to update private repo plugins from the admin at all? Would love that functionality, especially for smaller projects that are installed where there's no CLI access.
1
vote
1answer
27 views

How to set stability version in plugins?

I've made a plugin, that I'm now trying to include in a live project, but when I try to install it via the plugin installer, I get a 500 error, and if I try to include it using composer, I get the ...
1
vote
1answer
32 views

Order Adjusters in Commerce 2

In Craft Commerce 1, there is documentation on how to re-order adjustments that do similar things. https://docs.craftcms.com/commerce/v1/adjusters.html#ordering-adjustments But I don't see any ...
1
vote
0answers
15 views

Custom Element Reference Tags

I have created a custom element type and cant get the reference tags to parse correctly, I've set the refHandle and the action to copy reference tag which seems to be correct format when I copy a ...
1
vote
1answer
48 views

How to pragmatically set registered user status to pending and then manually send activation email

I have 2 front end registration forms. One for normal users and one for admins. In each form I have a hidden input with a group value like so: <input type="hidden" name="group" value="ypo"> In ...
1
vote
1answer
34 views

Ajax Post to Plugin Controller

I have been stuck on trying to make an ajax call to a custom plugin controller in Craft 2 for a few days after trying everything from following the documentation for Craft 2 as well as looking up ...
1
vote
1answer
20 views

Plugin not updating in the plugin store from changelog updates

I have a custom plugin registered with id.craftcms.com. The plugin store currently sees it at as 2.0.0, but I have since updated the plugin to 2.0.1 (and subsequently tried to force a silent 2.0.2 ...
1
vote
1answer
32 views

Get entries based on custom field lightswitch in custom plugin in Craft 2

I am trying to get the entries in my custom plugin template ( CP ) Each entry has a lightswitch I want to fetch only those where lightswitch is enabled. In controller file: $criteria = craft()->...
1
vote
1answer
13 views

How to access Plugin Variable in Plugin?

I want to access a variable created in Plugin itself. In Craft 2, it could be simply done by craft()->pluginName->getVar() but I couldn't find a way in Craft 3. I have tried Craft::$app->...
2
votes
0answers
33 views

Unable to register adjuster in module

Following https://docs.craftcms.com/commerce/v2/adjusters.html I am unable to register an adjuster in my module. in my Module.php file I have placed the following inside init() alongside other stuff ...
1
vote
1answer
26 views

Not able to catch exception sending SMS with Twilio in plugin

Not sure if this is the best place to post, but since it's a Craft 3 plugin I'll give it a shot. foreach ($numbers as $number){ $number = $twilio->lookups->v1->phoneNumbers($user->...
1
vote
1answer
31 views

How can I load the templates from a module?

I'm creating a module that contains some predefined templates. How can I load them directly out of the vendor folder? I've tried doing Event::on(View::class, View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS,...
1
vote
1answer
41 views

Ajax post request front-end csrf token

I'm trying to make a simple post request with ajax to a controller in plugin. The problem I'm having is that I always get a 400 Bad request because I don't send a valid CSRF Token. But I can't figure ...
1
vote
1answer
21 views

Open pop on click of custom action and get filled data

I created a new custom action. A new button is added in getAvailableActions() as we can se in below screenshot in red marked rectangle, now when i click on that button (Cusotm Action) i want to ...
1
vote
1answer
36 views

What variables are available to redirectToPostedUrl?

Craft's Web Controller has a redirectToPostedUrl method. Copied here for the sake of discussion: public function redirectToPostedUrl($object = null, string $default = null): YiiResponse { $url = ...
1
vote
1answer
45 views

Craft 3: how to call methods in another plugin's service?

In Craft 2, we used to be able to do so by doing: craft()->plugin1->myMethod(); from Plugin 2's service for example. Now in Craft 3, I couldn't figure out a way to do it. Plugin1::$plugin-&...
1
vote
1answer
31 views

Custom plugin field in Table Columns?

I just created my first Craft 3 plugin. In the plugin I also have a custom (select)field. Everything is working as expected, which is great! But I can't for the life of me figure out, how to add this ...
1
vote
2answers
129 views

Craft 3: Cron job to run Controller actionIndex method of a Plugin

I have made a Craft 3 plugin that is manually used in the Craft Admin CP area; click a button and we sync products in Craft with a Shopify API. Now I am trying to automate the process. I would like ...
0
votes
0answers
23 views

Iterate through Super Table field in plugin

I have a Super Table field with two columns, one is a category field, the other an assets field (limit 1 on both). How can I iterate through it to get the category and asset selected for each row in ...
3
votes
1answer
51 views

Element API calling Module that integrates with third-party plugin

This is probably a bit niche but anyone especially au fait with the element api here? On project X I have a custom module within which I am referencing a service from another plugin (bolden/google-...
1
vote
0answers
17 views

How to modifyPaymentRequest() in Commerce 2?

Looks that I really used every functionality in my plugin that changed or has been removed in Commerce 2. :( I need to modify paypal transactionId and description what i did as follows in Commerce 1: ...
0
votes
0answers
8 views

No EVENT_DEFAULT_ORDER_STATUS in craft\commerce\services\LineItems?

The Commerce 2 docs shows LineItems::EVENT_DEFAULT_ORDER_STATUS as a parameter for the event beforeSaveLineItem and afterSaveLineItem, but craft\commerce\services\LineItems did not have a constant ...
1
vote
1answer
38 views

How to duplicate a matrix field programatically in Craft 3.1?

Is there a "Craft" way of handling this in 3.1? Solutions to this question on SE are based on older versions of Craft which no longer work. Custom fields can be duplicated by doing: $newEntry->...
2
votes
2answers
37 views

How do I prevent a controller from creating unwanted routes?

I have a custom module that is adding sections to the CP, like this: // Register CP routes Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES, function(craft\events\...
0
votes
0answers
22 views

Commerce 1 create a new order programmatically

How can this be done in PHP? I can't find anything in the docs.
1
vote
2answers
22 views

Commerce 1 get customer from user model

In PHP, is it possible to grab the customer model from a user model? EDIT: I just noticed that it is possible to attach a customer info field to the user. How do we achieve this?
1
vote
1answer
52 views

Charge Plugin - Stripe payments occasionally not being received in craft

I have some Charge payments on my website, and I have registered the onCharge event in my plugin, like so: public function init() { parent::init(); craft()->on('charge.onCharge', function(...
0
votes
1answer
42 views

How to reset a multi-value checkbox using EVENT_AFTER_SAVE_ELEMENT in Craft 3?

I'm porting the functionality of an existing plugin from another CMS into Craft 3 through a custom Craft module. The functionality is: When an option from a multi-value checkbox is checked on the "...
1
vote
1answer
40 views

Private Plugin Repository Using Satis

Has anyone been successful using Satis for composer repo(s) with Craft plugins? I have a repo set up with artifacts, that are posted as a public composer repo in the network. It finds the plugins and ...
1
vote
2answers
47 views

How can I save a tag value in an entry in Craft 3

I am working on a plugin and I have the following code private function _tagProducts(array $products, array $names) { foreach ($products as $productId) { $product = Craft::$app->...
1
vote
1answer
39 views

Multiple and or relatedTo in plugin element criteria

I am trying to return entries that relate to a series of categories. For example, I am trying to return clothing, in this example, I want to return all entries related to (flannel or denim) and (blue ...
1
vote
1answer
18 views

Craft 2 - Returning Value in Variable from Plugin to Template

I am working with a plugin and wish to return a value from it to the template that calls it. In my plugin, there is an XML feed call, and I would like to pass a value(variable) from the plugin to the ...
1
vote
1answer
26 views

Lowering memory usage on task batches

I build a plugin for Craft 2 which imports data from an excel file into craft commerce products. The problem is that it needs to import excels with like 10.0000 rows and 30 columns. I made a simple ...
1
vote
1answer
17 views

Getting orders by property in Commerce 2 from Plugin

In Commerce 1 i can select orders by a specific property as follows: $criteria = craft()->elements->getCriteria('Commerce_Order'); $criteria['orderStatusId'] = 1; return craft()->elements-&...
1
vote
1answer
24 views

Is it possible to create a new multisite site via a Craft Plugin/Module?

Does Craft provide a way to programmatically add a new multisite site through a plugin or module?
1
vote
1answer
17 views

Checking if user authored an entry in another channel while in loop, N+1 problem

I have 2 channels set up: Channel A and Channel B. I also have public registration so users can log in and fill out two forms (Form A and Form B), each form creating an entry in their respective ...