Jump to content

Edit History

GoPure Kratom

GoPure Kratom

Thanks a LOT, awesome! I'm trying to make it work but have a couple of questions.

On the line below where the order status is changed, the code chokes on an exception, although the order's status gets updated(?!), but the execution is terminated to this line.

$history->changeIdOrderState((int)$order_state , $kb_order_obj, $use_existings_payment);

I'm trying to pass 2 as the $order_state which in my installation is the Payment Accepted.

PHP Notice:  Trying to get property 'precision' of non-object in /path/public_html/classes/Context.php on line 498
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision::getPrecision() must be of the type int, null given, called in /path/public_html/classes/Context.php on line 498 and defined in /path/public_html/src/Core/Localization/CLDR/ComputingPrecision.php:41
Stack trace:
#0 /path/public_html/classes/Context.php(498): PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision->getPrecision()
#1 /path/public_html/classes/order/Order.php(1465): ContextCore->getComputingPrecision()
#2 /path/public_html/classes/order/Order.php(1353): OrderCore->setInvoiceDetails()
#3 /path/public_html/classes/order/OrderHistory.php(371): OrderCore->setInvoice()
#4 /path/public_html/awtest.php(19): OrderHistoryCore->changeIdOrderState( in /path/public_html/src/Core/Localization/CLDR/ComputingPrecision.php on line 41

I think it has something to do with the first argument. is there something wrong witht he casting? I've tried plain number, variable, casted/uncasted.
I've checked the files in the stacktrace, and parameters and types passed seem to be ok to me.

Not sure if it matters, but I'm currently running this as a "standalone" php script and not as Presta standard file etc.

 

Here's the whole code:

<?php

require(dirname(__FILE__).'/config/config.inc.php');

$order_state = 2; //Payment Accepted
$bot_employee_id = 14;

$kb_order_obj = new Order(4617);
$history = new OrderHistory();

$history->id_order = $kb_order_obj->id;
$history->id_employee = (int)$bot_employee_id; // $this->context->employee->id;

$use_existings_payment = false;
if (!$kb_order_obj->hasInvoice()) {
         $use_existings_payment = true;
}

$history->changeIdOrderState((int)$order_state , $kb_order_obj, $use_existings_payment); 

// $carrier = new Carrier($kb_order_obj->id_carrier, $kb_order_obj->id_lang);

// $templateVars = array();

// if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $kb_order_obj->shipping_number) {
//     $templateVars = array('{followup}' => str_replace('@', $kb_order_obj->shipping_number, $carrier->url));
// }

// if ($history->addWithemail(true, $templateVars)) {
//     // synchronizes quantities if needed..
//     if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
//         foreach ($kb_order_obj->getProducts() as $product) {
//             if (StockAvailable::dependsOnStock($product['product_id'])) {
//                 StockAvailable::synchronize($product['product_id'],(int) $product['id_shop']);
//             }
//         }
//     }
// }

echo "Order ID: ".$kb_order_obj->id."\n";
echo "Order reference: ".$kb_order_obj->reference."\n";

?>

 

GoPure Kratom

GoPure Kratom

Thanks a LOT, awesome! I'm trying to make it work but have a couple of questions.

On the line below where the order status is changed, the code chokes on an exception, although the order's status is updated(?!), but the execution is terminated to this line.

$history->changeIdOrderState((int)$order_state , $kb_order_obj, $use_existings_payment);

I'm trying to pass 2 as the $order_state which in my installation is the Payment Accepted.

PHP Notice:  Trying to get property 'precision' of non-object in /path/public_html/classes/Context.php on line 498
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision::getPrecision() must be of the type int, null given, called in /path/public_html/classes/Context.php on line 498 and defined in /path/public_html/src/Core/Localization/CLDR/ComputingPrecision.php:41
Stack trace:
#0 /path/public_html/classes/Context.php(498): PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision->getPrecision()
#1 /path/public_html/classes/order/Order.php(1465): ContextCore->getComputingPrecision()
#2 /path/public_html/classes/order/Order.php(1353): OrderCore->setInvoiceDetails()
#3 /path/public_html/classes/order/OrderHistory.php(371): OrderCore->setInvoice()
#4 /path/public_html/awtest.php(19): OrderHistoryCore->changeIdOrderState( in /path/public_html/src/Core/Localization/CLDR/ComputingPrecision.php on line 41

I think it has something to do with the first argument. is there something wrong witht he casting? I've tried plain number, variable, casted/uncasted.

 

Here's the whole code:

<?php

require(dirname(__FILE__).'/config/config.inc.php');

$order_state = 2; //Payment Accepted
$bot_employee_id = 14;

$kb_order_obj = new Order(4617);
$history = new OrderHistory();

$history->id_order = $kb_order_obj->id;
$history->id_employee = (int)$bot_employee_id; // $this->context->employee->id;

$use_existings_payment = false;
if (!$kb_order_obj->hasInvoice()) {
         $use_existings_payment = true;
}

$history->changeIdOrderState((int)$order_state , $kb_order_obj, $use_existings_payment); 

// $carrier = new Carrier($kb_order_obj->id_carrier, $kb_order_obj->id_lang);

// $templateVars = array();

// if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $kb_order_obj->shipping_number) {
//     $templateVars = array('{followup}' => str_replace('@', $kb_order_obj->shipping_number, $carrier->url));
// }

// if ($history->addWithemail(true, $templateVars)) {
//     // synchronizes quantities if needed..
//     if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
//         foreach ($kb_order_obj->getProducts() as $product) {
//             if (StockAvailable::dependsOnStock($product['product_id'])) {
//                 StockAvailable::synchronize($product['product_id'],(int) $product['id_shop']);
//             }
//         }
//     }
// }

echo "Order ID: ".$kb_order_obj->id."\n";
echo "Order reference: ".$kb_order_obj->reference."\n";

?>

 

GoPure Kratom

GoPure Kratom

Thanks a LOT, awesome! I'm trying to make it work but have a couple of questions.

On the line below where the order status is changed, the code chokes on an exception, although the order's status is updated(?!), but the execution is terminated to this line.

$history->changeIdOrderState((int)$order_state , $kb_order_obj, $use_existings_payment);

I'm trying to pass 2 as the $order_state which in my installation is the Payment Accepted.

PHP Notice:  Trying to get property 'precision' of non-object in /path/public_html/classes/Context.php on line 498
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision::getPrecision() must be of the type int, null given, called in /path/public_html/classes/Context.php on line 498 and defined in /path/public_html/src/Core/Localization/CLDR/ComputingPrecision.php:41
Stack trace:
#0 /path/public_html/classes/Context.php(498): PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision->getPrecision()
#1 /path/public_html/classes/order/Order.php(1465): ContextCore->getComputingPrecision()
#2 /path/public_html/classes/order/Order.php(1353): OrderCore->setInvoiceDetails()
#3 /path/public_html/classes/order/OrderHistory.php(371): OrderCore->setInvoice()
#4 /path/public_html/awtest.php(19): OrderHistoryCore->changeIdOrderState( in /path/public_html/src/Core/Localization/CLDR/ComputingPrecision.php on line 41

I think it has something to do with the first argument. is there something wrong witht he casting? I've tried plain number, variable, casted/uncasted.

-----

Also another thing, my script does not "know" the ID of the order, but it gets an order reference as an input.
I tried to get an Order object with a reference, but the aproach I'm trying seems to just produce an empty object with only the reference passed:

$order_obj = Order::getByReference($awx_data->data->reference);
if($order_obj)
    echo "Order True\n";
else
    echo "Order false\n";

What's the proper way of getting an order using order reference (or an id_order) using the reference?

 

Here's the whole code (with using id_order at this point):

<?php

require(dirname(__FILE__).'/config/config.inc.php');

$order_state = 2; //Payment Accepted
$bot_employee_id = 14;

$kb_order_obj = new Order(4617);
$history = new OrderHistory();

$history->id_order = $kb_order_obj->id;
$history->id_employee = (int)$bot_employee_id; // $this->context->employee->id;

$use_existings_payment = false;
if (!$kb_order_obj->hasInvoice()) {
         $use_existings_payment = true;
}

$history->changeIdOrderState((int)$order_state , $kb_order_obj, $use_existings_payment); 

// $carrier = new Carrier($kb_order_obj->id_carrier, $kb_order_obj->id_lang);

// $templateVars = array();

// if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $kb_order_obj->shipping_number) {
//     $templateVars = array('{followup}' => str_replace('@', $kb_order_obj->shipping_number, $carrier->url));
// }

// if ($history->addWithemail(true, $templateVars)) {
//     // synchronizes quantities if needed..
//     if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
//         foreach ($kb_order_obj->getProducts() as $product) {
//             if (StockAvailable::dependsOnStock($product['product_id'])) {
//                 StockAvailable::synchronize($product['product_id'],(int) $product['id_shop']);
//             }
//         }
//     }
// }

echo "Order ID: ".$kb_order_obj->id."\n";
echo "Order reference: ".$kb_order_obj->reference."\n";

?>

 

GoPure Kratom

GoPure Kratom

Thanks a LOT, awesome! I'm trying to make it work but have a couple of questions.

On the line where the order status is changed, the code chokes on an exception, although the order's status is changed before the execution is temrinated.

$history->changeIdOrderState((int)$order_state , $kb_order_obj, $use_existings_payment);

Here, I'm trying to pass 2 as the $order_state which in my installation is the Payment Accepted.

PHP Notice:  Trying to get property 'precision' of non-object in /path/public_html/classes/Context.php on line 498
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision::getPrecision() must be of the type int, null given, called in /path/public_html/classes/Context.php on line 498 and defined in /path/public_html/src/Core/Localization/CLDR/ComputingPrecision.php:41
Stack trace:
#0 /path/public_html/classes/Context.php(498): PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision->getPrecision()
#1 /path/public_html/classes/order/Order.php(1465): ContextCore->getComputingPrecision()
#2 /path/public_html/classes/order/Order.php(1353): OrderCore->setInvoiceDetails()
#3 /path/public_html/classes/order/OrderHistory.php(371): OrderCore->setInvoice()
#4 /path/public_html/awtest.php(19): OrderHistoryCore->changeIdOrderState( in /path/public_html/src/Core/Localization/CLDR/ComputingPrecision.php on line 41

I think it has something to do with the first argument. is there something wrong witht he casting? I've tried plain number, variable, casted/uncasted.

Also, my script does not "know" the ID of the order, but it gets an order reference as an input.
I tried to get an Order object with a reference, but the aproach I'm trying seems to just produce an empty object with only the reference passed:

$order_obj = Order::getByReference($awx_data->data->reference);
if($order_obj)
    echo "Order True\n";
else
    echo "Order false\n";

What's the proper way of getting an order using order reference (or an id_order) using the reference?

 

Here's the whole code (with using id_order at this point):

<?php

require(dirname(__FILE__).'/config/config.inc.php');

$order_state = 2; //Payment Accepted
$bot_employee_id = 14;

$kb_order_obj = new Order(4617);
$history = new OrderHistory();

$history->id_order = $kb_order_obj->id;
$history->id_employee = (int)$bot_employee_id; // $this->context->employee->id;

$use_existings_payment = false;
if (!$kb_order_obj->hasInvoice()) {
         $use_existings_payment = true;
}

$history->changeIdOrderState((int)$order_state , $kb_order_obj, $use_existings_payment); 

// $carrier = new Carrier($kb_order_obj->id_carrier, $kb_order_obj->id_lang);

// $templateVars = array();

// if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $kb_order_obj->shipping_number) {
//     $templateVars = array('{followup}' => str_replace('@', $kb_order_obj->shipping_number, $carrier->url));
// }

// if ($history->addWithemail(true, $templateVars)) {
//     // synchronizes quantities if needed..
//     if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
//         foreach ($kb_order_obj->getProducts() as $product) {
//             if (StockAvailable::dependsOnStock($product['product_id'])) {
//                 StockAvailable::synchronize($product['product_id'],(int) $product['id_shop']);
//             }
//         }
//     }
// }

echo "Order ID: ".$kb_order_obj->id."\n";
echo "Order reference: ".$kb_order_obj->reference."\n";

?>

 

×
×
  • Create New...