1
0
Fork 0
mirror of synced 2025-04-06 07:13:33 +03:00

fix invalid payment in built order & create order from adminpanel

This commit is contained in:
Pavel 2020-02-14 16:30:05 +03:00 committed by Павел
parent 1492516429
commit a93f7ad4ed
3 changed files with 20 additions and 2 deletions

View file

@ -104,6 +104,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
if (!$this->get_option('deactivate_update_order')
|| $this->get_option('deactivate_update_order') == static::NO
) {
add_action('woocommerce_new_order', array($this, 'create_order'), 11, 1);
add_action('woocommerce_update_order', array($this, 'update_order'), 11, 1);
}

View file

@ -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);
}

View file

@ -50,6 +50,7 @@ class WC_Retailcrm_Order_Payment extends WC_Retailcrm_Abstracts_Data
*/
public function build($order, $externalId = false)
{
$this->reset_data();
$data = array();
if (!empty($this->settings['send_payment_amount'])
@ -84,11 +85,27 @@ class WC_Retailcrm_Order_Payment extends WC_Retailcrm_Abstracts_Data
}
}
$this->set_data_fields(WC_Retailcrm_Plugin::clearArray($data));
$this->set_data_fields($data);
return $this;
}
/**
* Returns false if payment doesn't have method
*
* @return array
*/
public function get_data()
{
$data = parent::get_data();
if (empty($data['type'])) {
return array();
}
return $data;
}
public function reset_data()
{
$this->data = array(