Replies: 2 comments 3 replies
-
The module appears to be properly registered and installed. However, it's not clear from your code why the module is not working. It's possible that the hook is not being triggered properly, or that the conditions for updating the order status are not being met. One thing you could try is to add some debug statements to your code to see where it's getting stuck. For example, you could add some "echo" statements to output some debug information, or use a debugging tool like Xdebug to step through the code and see what's happening. Additionally, you might consider adding some error handling to your code to catch any potential issues that might arise. For example, you could add some try-catch blocks to catch any exceptions that might be thrown, or use the PrestaShop logger to log any errors or warnings. |
Beta Was this translation helpful? Give feedback.
-
Also, you can benefit syntax highlighting after writing language name after ``` print "Who wouldn't love syntax highlighting?";
if $colorblind {
print 'Amateurs';
} |
Beta Was this translation helpful? Give feedback.
-
I've tried to make a module that automatically changed the status of new orders depending on payment method, stock levels and warehouses, but I've got to a point where there are no errors but the module is just no doing anything at all.
The module is triggered when new orders are placed. All products have to be in stock. Then depending on which payment method is chosen by the customer, the module will change the order status to a certain ID.
For example, in my code what I want is:
if all products are in stock and customer chose payment by bankwire, then this module changes the status of the order to one that sends email instructions for payment
Same for COD method
In the case of CC payments, it will put the order in preparation depending on (ASM) the warehouses of the products in the order:
All products on Warehouse A
All products on Warehouse B
Products on A & B
You may say, why not doing this directly from the payment modules? simple, because we allow pre-orders on products not available in stock, and for those cases we need to check first with suppliers before sending further instructions to customers or putting the order in preparation.
This is how I wrote the code:
`<?php
if (!defined('PS_VERSION')) {
exit;
}
class AutoStatusUpdate extends Module
{
public function __construct()
{
$this->name = 'autostatusupdate';
$this->tab = 'administration';
$this->version = '1.0.0';
$this->author = 'Me';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => PS_VERSION);
$this->bootstrap = true;
public function hookActionObjectOrderAddAfter($params)
{
// Retrieve the order and cart objects from the hook parameters
$order = $params['object'];
$cart = $params['cart'];
// Get the payment method used for the order
$payment_method = $order->module;
}
}`
Beta Was this translation helpful? Give feedback.
All reactions