/** * Get the total amount of the upgrade discount. * * @since 1.0 * * @param bool $format * * @return float|string */ public function get_discount($format = false) { $transaction = $this->key->get_transaction(); foreach (it_exchange_get_transaction_products($transaction) as $product) { if ($product['product_id'] == $this->key->get_product()->ID) { return $product['product_base_price']; } } return 0.0; }
/** * Action called when a transaction order is updated from iT Exchange */ function iditexch_update_order($args) { $transaction_id = $args['ID']; // Getting the products involved in the transaction/payment $products = it_exchange_get_transaction_products($transaction_id); if (is_array($products)) { $id_orders = array(); $count = 1; foreach ($products as $cart_id => $data) { $product_id = $data['product_id']; $qty = $data['count']; $price = $data['product_subtotal']; $vars = iditexch_payment_vars($transaction_id, $product_id, $price, $count); for ($i = 0; $i < $qty; $i++) { // Adding order separately for each number of product quantity $rc = new ReflectionClass('ID_Order'); $order = $rc->newInstanceArgs($vars); $check = $order->check_new_order($vars['transaction_id'] . "-" . $i); if (isset($check)) { $pay_id = $check->id; if (isset($pay_id) && $pay_id > 0) { $vars['id'] = $pay_id; $rc = new ReflectionClass('ID_Order'); // Adding quantity number to transaction_id $vars['transaction_id'] = $vars['transaction_id'] . "-" . $i; $order = $rc->newInstanceArgs($vars); $update = $order->update_order(); } } } $count++; } } }