Re: Edit Orders v4.0 Support Thread
admin/includes/classes/editOrders.php lines 270, 274: should $this->shipping_tax_rate be cast as a float in case it's null?
(Getting SQL error on line 270)
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
swguy
Investigating ...
admin/includes/functions/extra_functions/edit_orders_functions.php lines 1429-1445 you are referencing $order->totals[$i]['class'].
This should be $order->totals[$i]['code'] shouldn't it?
(lines are same between EO 4.5.0 and 4.5.1)
Nope, the $order->totals array is 'indexed' by its class element.
The $order_total_modules, just to make life interesting, returns each module's entry with a reference to its code (aka the order's class) element.
1 Attachment(s)
Re: Edit Orders v4.0 Support Thread
As created by the class, yes - but by the time it gets to eo_update_database_order_totals, the array entries have been changed. See screenshot.
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
swguy
The root cause of the deleted tax line is in the block that handles the "rogue" ot_tax value.
(Around 1449 of ./includes/functions/extra_functions/edit_orders_functions.php).
My tax title is Sales tax (if any) + Shipping Tax (0.0000%) + Tax:
which does not work for the clause
`title` NOT IN ($tax_groups)
Perhaps a LIKE would be better - something like
Code:
foreach ($tax_groups as &$tax_group) {
$tax_group = '%' . $db->prepareInput($tax_group) .'%'. ':';
}
$tax_groups = "'" . implode("', '", $tax_groups) . "'";
...
$query =
"DELETE FROM " . TABLE_ORDERS_TOTAL . "
WHERE orders_id = $oID
AND `class` = 'ot_tax'
AND `title` NOT IN (";
for ($i = 0; $i < count($tax_groups); $i++) {
if ($i > 0) $query .= ",";
$query .= $tax_groups[$i];
}
$query .= ")";
Hmm, looks like you've got My Store::Show Split Tax Lines set to false. Let me investigate further.
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
swguy
As created by the class, yes - but by the time it gets to eo_update_database_order_totals, the array entries have been changed. See screenshot.
You're displaying the contents of the $order_totals array, as returned by $order_total_modules->process, not the contents of $order->totals.
Re: Edit Orders v4.0 Support Thread
Aside: sorry, that suggested code didn't come out quite right - I was thinking a LIKE with all strings concatenated with % between strings (and before and after).
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
lat9
You're displaying the contents of the $order_totals array, as returned by $order_total_modules->process, not the contents of $order->totals.
CRAP! You are correct, sorry for the false report.
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
swguy
admin/includes/classes/editOrders.php lines 270, 274: should $this->shipping_tax_rate be cast as a float in case it's null?
(Getting SQL error on line 270)
It's taken a long time to get all those other float-casts out of EO (trying to get rid of those penny-off calculations), but I'll update this section of the class' initializeOrderShippingTax method:
Code:
switch ($action) {
case 'update_order':
$this->shipping_tax_rate = $_POST['shipping_tax'];
$order->info['shipping_tax'] = $this->calculateOrderShippingTax(true);
break;
case 'add_prdct':
$this->shipping_tax_rate = $tax_rate->fields['shipping_tax_rate'];
$order->info['shipping_tax'] = $this->eoRoundCurrencyValue(zen_calculate_tax($order->info['shipping_cost'], $this->shipping_tax_rate));
break;
default:
$this->shipping_tax_rate = $tax_rate->fields['shipping_tax_rate'];
$order->info['shipping_tax'] = $this->calculateOrderShippingTax(false);
break;
}
to sanitize that value on entry.
See this GitHub issue for follow-on: https://github.com/lat9/edit_orders/issues/157
Re: Edit Orders v4.0 Support Thread
As an alternative, you could not do the update when the value is null. But I'm ok with either solution. Thanks!
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
lat9
It's taken a long time to get all those other float-casts out of EO (trying to get rid of those penny-off calculations), but I'll update this section of the class'
initializeOrderShippingTax method:
Code:
switch ($action) {
case 'update_order':
$this->shipping_tax_rate = $_POST['shipping_tax'];
$order->info['shipping_tax'] = $this->calculateOrderShippingTax(true);
break;
case 'add_prdct':
$this->shipping_tax_rate = $tax_rate->fields['shipping_tax_rate'];
$order->info['shipping_tax'] = $this->eoRoundCurrencyValue(zen_calculate_tax($order->info['shipping_cost'], $this->shipping_tax_rate));
break;
default:
$this->shipping_tax_rate = $tax_rate->fields['shipping_tax_rate'];
$order->info['shipping_tax'] = $this->calculateOrderShippingTax(false);
break;
}
to sanitize that value on entry.
See this GitHub issue for follow-on:
https://github.com/lat9/edit_orders/issues/157
Update provided; see that issue for the change required.