set item discount to zero if no discount applies
This commit is contained in:
parent
318d3318a8
commit
1492516429
3 changed files with 7 additions and 6 deletions
|
@ -483,7 +483,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
|
|||
$this->order_payment->is_new = true;
|
||||
$order_data['payments'][] = $this->order_payment->build($order)->get_data();
|
||||
}
|
||||
|
||||
|
||||
$this->order = apply_filters('retailcrm_process_order', WC_Retailcrm_Plugin::clearArray($order_data), $order);
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ class WC_Retailcrm_Plugin {
|
|||
? self::clearArray($node)
|
||||
: $node;
|
||||
|
||||
if ($result[$index] == ''
|
||||
if ($result[$index] === ''
|
||||
|| $result[$index] === null
|
||||
|| (is_array($result[$index]) && count($result[$index]) < 1)
|
||||
) {
|
||||
|
|
|
@ -66,10 +66,10 @@ class WC_Retailcrm_Order_Item extends WC_Retailcrm_Abstracts_Data
|
|||
$this->set_data_fields($data);
|
||||
$this->set_offer($item);
|
||||
|
||||
if ($this->settings['api_version'] == 'v5' && round($discount_price, 2)) {
|
||||
$this->set_data_field('discountManualAmount',round($discount_price, 2));
|
||||
} elseif ($this->settings['api_version'] == 'v4' && round($discount_price, 2)) {
|
||||
$this->set_data_field('discount', round($discount_price, 2));
|
||||
if ($this->settings['api_version'] == 'v5') {
|
||||
$this->set_data_field('discountManualAmount', (float) round($discount_price, 2));
|
||||
} elseif ($this->settings['api_version'] == 'v4') {
|
||||
$this->set_data_field('discount', (float) round($discount_price, 2));
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -114,6 +114,7 @@ class WC_Retailcrm_Order_Item extends WC_Retailcrm_Abstracts_Data
|
|||
* @param $price
|
||||
*
|
||||
* @return float|int
|
||||
* @todo Rounding issues with prices in pennies / cents should be expected here.
|
||||
*/
|
||||
private function calculate_discount(WC_Order_Item_Product $item, $price)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue