User specifies payment method and subscription status changes from pending to active. When woocommerce_subscription_status_updated action is called, instance of WC_Subscription is passed as argument. Why is payment_method blank inside this instance?
Related
I am working on a system where I need to send orders to another system using the other system's API, I have a setup that works for 95% of the orders, but a few orders do not trigger my action hook and I can not figure out why a few orders to trigger the action:
add_action( 'woocommerce_order_status_processing', array( $this, 'new_order_processing' ),1 );
Is there another hook I should use to ensure that new_order_processing is triggered on all new orders and why is the hook not always triggered? The customers only have one payment option bank transfer.
(The orders that do not trigger the 'woocommerce_order_status_processing' action do have the status processing when looking inside Woocommerce.)
In my A/B testing (with Remote Configs), I want to know which variant performed better based on daily user engagement.
As I can not see the built-in goal metric "Daily user engagement" in the dashboard, so I want to create my custom.
Could I track an event with parameter VALUE and set it as a goal metric (based on its value) in A/B testing?
This is how want to do:
// Firebase Unity SDK
FirebaseAnalytics.LogEvent("time_spent", FirebaseAnalytics.ParameterValue, time_spent_in_seconds);
Thank you.
Declare an event in the class where you want the vent to be fired. I dont know the type of FirebaseAnalytics.ParameterValue as I am not familiar with firebase nor with your app. I will assume its a string:
public event EventHandler<string> raiseFirebaseEvent;
Wherever in your code (normally a different class where the event is declared, and after invoked which is the same) you need to add a listener to this event, this means to add a method to the event, to be called after in the event trigger.
In this other class you will have a method that will be the one to subscribe to the event:
prevate void FireBaseLogger(FirebaseAnalytics.ParameterValue value) {
FirebaseAnalytics.LogEvent("time_spent", value,
time_spent_in_seconds);
}
time_spent_in_seconds shoul be a variable of this other class I guess.
Somewhere in this class, usually in the constructor, or somewhere you know for sure that the code ejecution will go through there, you should subscribe to the event. For this you need a reference of your event holder class, where the event was declared:
EventHolderClassInstance.raiseFirebaseEvent += FireBaseLogger;
No arguments are passed in the subscription, just the method.
Then, in your EventHolderClass, when you invoke the event, passing the string parameter, the subscribed method will be called as long as the subscription was done prior the invocation.
raiseFirebaseEvent?.Invoke(this, FirebaseAnalytics.ParameterValue);
When there are no methods subscribed raiseFirebaseEvent is null, that is what the question mark is for. If there was no previous subscription raiseFirebaseEvent is null, and nothing happens.
In case FirebaseAnalytics.ParameterValueis not string type, change the type accordingly in the event and in the private method subscribed in the class where the listener is added, or where the subscription is made that means the same.
Not sure if that is what you were asking.
I want to call new actions as I complete the conversation with the user on the secondary receiver protocol and I also want to pass the thread again to the primary receiver.
After the conversation ended, I want my chatbot to be started again.
To restart the conversation, include Restarted() in the events returned from your last custom action:
class ActionName(Action):
def name(self):
...
return "action_name"
def run(self, dispatcher, tracker, domain):
...
return [Restarted()]
You can customise action_session_start to check some condition and pass it to the appropriate receiver as well
For example in the user module there is a hook_user_login hook
When a user logs in in function user_login_finalize() will be called, then user_login_finalize will call user_module_invoke('login', $edit, $user);
that will call system_user_login (and others module's function[moudulename_user_login] that implements hook_user_login());
I am puzzled at which function will call hook_user_login() and when it will be Invoked. What is the role of this function?
As you mentioned, the user_login_finalize will call user_module_invoke('login', $edit, $user).
The user_module_invoke function will then look at the first argument of the function (login) and based on that value it will call the hook_user_login() function.
The main goal for a module to implement the hook_user_login() function is to be notified that a user just logged in, so it can take additional actions: add additional information to the database, write a special message to the screen if it is the user his/her birthday, etc ...
I have a Command that executes a service call. In the result handler, I am doing some logic based off the result data. If the logic meets specific criteria, I am displaying a confirmation popup. If the user clicks the continue button in the confirmation popup, I have a method that gets called, which dispatches a Parsley event. That Parsley event is not being caught. However, if I dispatch the Parsley event from inside the result method, it is being caught. Any idea why the event is not being caught when dispatching it from outside the result method?
For example...
[MessageDispatcher]
[Bindable]
public var dispatcher:Function;
I execute some service call from inside the command:
public function execute(event:SomeEvent):AsyncToken
{
return service.callService(event.type, false);
}
I now have a result handler like this:
public function result(data:Object):void
{
if (add some logic here based off data)
AlertHelper.showContinueQuestion(onSelection, "Are you sure you want to continue?");
}
If the user clicks the Continue button on the confirmation popup, it calls the onSelection method:
private function onSelection():void
{
dispatcher(new SomeEvent(SomeEvent.UPLOAD));
}
That Parsley event, SomeEvent, is not being caught. However, if I dispatch that event after the if statement, it is being caught and works fine. Any idea why it is not being caught when dispatched from outside of the result handler? I tried in other commands too, and it does the same thing.
Found this on the Spicefactory site, works as designed. I ended up updating a flag in the Model, versus dispatching an event. I then have a BindSetter listening for changes to that flag in the model. When the flag is set to true, the Parsley event is dispatched.
Command Object Lifecycle
Apart from grouping the executing method and the result handlers the DynamicCommand also introduces a special kind of lifecycle management for command objects. The creation of the object does not happen until a matching message is dispatched. It then becomes a container managed object just for the duration of the command execution. It will immediately be removed from the Context after the result or error handler have been invoked. But during its lifetime, it is a fully managed object, can have its dependencies injected, or even take part in messaging during the command execution. But that would be a rather rare case, most common usage scenario is probably the command object just receiving all the dependencies it needs to execute the command.