My problem is, that second parameter in plgVmOnUpdateOrderPayment event is actually old status code before change.
Did anybody knows, how to get new status letter after changing order status via e.g. paypal plugin or in administration?
Aleš Pázner, yes the second parameter is always the old order status.
But you can use this piece of code:
function plgVmOnUpdateOrderPayment($virtuemart_order,$old_status) {
// getting the new status
// $virtuemart_order->order_status
return;
}
Source: Plugin event methods in Virtuemart for order status
Related
hey I was trying to make a plugin that sends WhatsApp messages on order status change so this is my code
add_action("woocommerce_order_status_changed", "order_status_wapp",10,3);
function order_status_wapp($order_id, $old_status, $new_status){
if( $new_status == "processing" && carbon_get_theme_option( 'show_processing' )) { require("incl/apicall.php");
$message = carbon_get_theme_option( 'processing_message' );
require("incl/message_attr.php");
}
the code is working well when changing the status from the order table area ( actions ), but changing the status from the order details or programmatically shows no effect. is there any hook that triggers status change no matter what the way of changing is?
in the end, it worked.
My issue was that I was testing the event with the ACF Update field, which did not work.
However, when I changed it to the main event (send SMS), it worked perfectly.
I am using a payment module with Prestashop 1.6, everything was working fine until an upgrade happened. The payment server return the validation data to an url like "http://..../validation.php".
This file tries to get the order using the cart id that is returned by the server and obviously cant find it, hence the cart is not emptied and the order not created.
I added logs into that file to see what is received. The CartID (data['reference']) is correct.
writeMessage("Trying to get the order id using the cart:".$data['reference']);
writeMessage(Order::getOrderByCartId((int)($data['reference'])));
if ($id_order = intval(Order::getOrderByCartId((int)($data['reference']))))
{
writeMessage("Got the order by cart id.");
writeMessage("Got the order by cart id:".$id_order);
$order = new Order($id_order);
...
I am wondering if the call to Order::getOrderByCartId is correct. Is it the right way to call this function?
Any idea?
I can answer my question. The issue was not on the call to getOrderByCartId as it is normal that at this moment the order is not created yet.
The issue is actually on the validation function of the module, second part of the if.
$module->validateOrder(intval($data['reference']), $orderStatus, $amount, $module->displayName, $orderMessage, NULL, $id_currency, true, $customer->secure_key);
I implement the example from facebook credits, and create an test app, added the callback.php in the Callback Url, place my keys correctly. but I get this error:
Sorry, but we're having trouble processing your payment. You have not been charged for this transaction. Please try again.
I am trying to create a few buttons with different monetary values. Like:
Click to get 100 credits
Click to get 1000 credits
If I use this generic code, I get the payment window just fine, but I can't see my products there, I can only choose from already made presets :
function buyMore(){
// calling the API ...
var obj = {
app_id: 'xxxxxxxxxxxxxxxxxxxxx',
method: 'pay',
order_info: n,
purchase_type: 'item',
credits_purchase: true
};
to show the user my monetary presets I think I need to pass different values to the function:
<p><a onclick="buyMore('100'); return false;">Buy More Credits 100</a></p>
<p><a onclick="buyMore('1000'); return false;">Buy More Credits 1000</a></p>
function buyMore(price) {
var order_info = {
"title":'title',
"description":'description',
"price":price,
"image_url":'http://....img_url',
"product_url":'http://....product_url'
};
// calling the API ...
var obj = {
app_id: '153230661424821',
method: 'pay',
order_info: order_info,
purchase_type: 'item'
};
}
Not sure if I got it right.
Can anyone push me in the right direction?
Yeah, you'll have to have your users select the item they want to purchase, which will then call the buyMore function to have them confirm their purchase via the Credits dialog (like you're doing in your second example).
First thing I'd do is check my Credits setting in the Developer app though. I've gotten that error before on a new app before realizing I'd forgotten to set my credits callback URL or set my user as a Credits test user.
Why are you asking the user to buy a set number of credits?
Surely it's an easier flow if you ask the user to buy an item (priced in credits) and Facebook handles the step of the user buying the necessary credits themselves?
I'm writing an observer for the *checkout_submit_all_after* event and it works fine. When you edit an order, for example the #1001, magento creates a new one with #1001-1 and cancel the previous order.
The admin panel tells me that #1001-1 is linked to the #1001, so how can I know if the current order is actually a modified version?
Is there some function/variable for this purpose?
thanks
I did it!
$current_id = $order->getRealOrderId(); // #1001-2
$previous_id = $order->getRelationParentRealId(); // #1001-1
$older_id = $order->getOriginalIncrementId(); // #1001
I am trying to write a module that syncs my newsletter subscribers in Magento with a external database. I need to be able to update the subscription status in Magento programmatically but I am having diffuculty getting the "setStatus" method in Magento to work. It does not throw any errors but the code does not seem to have any effect. Below is the code where I call the method:
$collection = Mage::getResourceModel('newsletter/subscriber_collection')->showStoreInfo()->showCustomerInfo();
foreach ($collection as $cust) {
$cust->setStatus(1);
}
In theory, this should set the status of all of my subscribers to "subscribed". I could optionally change the argument sent to "setStatus" to any of the below ints for a different status.
1: Subscribed
2: Status Not Active
3: Unsubscribed
How to best change the subscriber status or get this code working?
Here an import script:
<?php
require_once("./app/Mage.php");
Mage::app();
$subscribers = array('email1#server1.com', 'email2#server2.com');
foreach ($subscribers as $email) {
# create new subscriber without send an confirmation email
Mage::getModel('newsletter/subscriber')->setImportMode(true)->subscribe($email);
# get just generated subscriber
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
# change status to "subscribed" and save
$subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
$subscriber->save();
}
?>
It seems that newsletter subscribers are also stored elsewhere. What you are setting is just a check in the customer base for some other use.
You need to do the following for each customer as well.
Mage::getModel('newsletter/subscriber')->subscribe($email);
See this link for a complete reference.
Thanks to the link #Ozair shared I was able to figure out what I needed to do.
I was successfully setting the status of the subscriber in the Magento subscriber object but I was not saving the object. I needed to call Magento's save method so it would call the ORM and write it to the database. All I need to do was add
$cust->save();
in the for loop. Below is the whole code snippet.
$collection = Mage::getResourceModel('newsletter/subscriber_collection')->showStoreInfo()->showCustomerInfo();
foreach ($collection as $cust) {
$cust->setStatus(1);
$cust->save();
}
I Hope this helps someone in the future. I needed it for a Constant Contact - Magento Synchronization extension I was making: http://www.freelunchlabs.com/store/constant-contact-and-magento-sync.html