So for six months this has worked perfectly. Until now. Yet nothing's changed! I just updated to HikaShop Starter V2.2.0 just in case something changed with PayPal. What's even more frustrating is that sometimes it's working, sometimes it's not - though all of my most recent orders have failed.
After putting various debugging into the plugin and my own code, here is what have:
function onAfterOrderCreate(&$order,&$send_email){
if(!empty($order->order_id)){
$class = hikashop_get('class.user');
$user = $class->get($order->order_user_id);
foreach($order->cart->products as $product){
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/xxxxxxx/hikalicense.php";
include_once($path);
hikalicense_create($order->order_id, $product->product_id, $user->user_cms_id, $product->order_product_quantity);
}
}
$send_email = false;
return true;
}
Just before the "return true" I put some debugging in which correctly gets triggered, so I know that execution is returning from my stuff and back into the HikaShop code. I also have this code, in the same file:
function onAfterOrderUpdate(&$order,&$send_email){
if(!empty($order->order_id)){
if($order->order_status == 'confirmed'){
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/xxxxxx/hikalicense.php";
include_once($path);
hikalicense_confirm($order->order_id);
}
} // if
return true;
}
Now, admittedly I'm struggling to determine whether this actually gets called. However, I do know from the database that the order_status is created, not confirmed, so the second "if" fails.
I only have a PayPal payment method so everything is through that. When a customer orders a product I get an email from PayPal to confirm that payment has been made, with the HikaShop order number contained in that email. So it would seem that somehow there is a PayPal->payment confirmed->HikaShop order confirmed interaction issue. I've no ideas why though, whether it's a misconfiguration on my end or whatever. Any ideas appreciated.