本文整理汇总了PHP中WC_Order::get_product_from_item方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::get_product_from_item方法的具体用法?PHP WC_Order::get_product_from_item怎么用?PHP WC_Order::get_product_from_item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Order
的用法示例。
在下文中一共展示了WC_Order::get_product_from_item方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_edit_address_subscription_action
/**
* Add a "Change Shipping Address" button to the "My Subscriptions" table for those subscriptions
* which require shipping.
*
* @param array $all_actions The $subscription_key => $actions array with all actions that will be displayed for a subscription on the "My Subscriptions" table
* @param array $subscriptions All of a given users subscriptions that will be displayed on the "My Subscriptions" table
* @since 1.3
*/
public static function add_edit_address_subscription_action($all_actions, $subscriptions)
{
foreach ($all_actions as $subscription_key => $actions) {
$order = new WC_Order($subscriptions[$subscription_key]['order_id']);
$needs_shipping = false;
foreach ($order->get_items() as $item) {
if ($item['product_id'] !== $subscriptions[$subscription_key]['product_id']) {
continue;
}
$product = $order->get_product_from_item($item);
if (!is_object($product)) {
// In case a product has been deleted
continue;
}
if ($product->needs_shipping()) {
$needs_shipping = true;
}
}
if ($needs_shipping && in_array($subscriptions[$subscription_key]['status'], array('active', 'on-hold'))) {
// WC 2.1+
if (function_exists('wc_get_endpoint_url')) {
$all_actions[$subscription_key] = array('change_address' => array('url' => add_query_arg(array('subscription' => $subscription_key), wc_get_endpoint_url('edit-address', 'shipping')), 'name' => __('Change Address', 'woocommerce-subscriptions'))) + $all_actions[$subscription_key];
} else {
$all_actions[$subscription_key] = array('change_address' => array('url' => add_query_arg(array('address' => 'shipping', 'subscription' => $subscription_key), get_permalink(woocommerce_get_page_id('edit_address'))), 'name' => __('Change Address', 'woocommerce-subscriptions'))) + $all_actions[$subscription_key];
}
}
}
return $all_actions;
}
示例2: complete_order
/**
* Complete virtual booking orders
*/
public function complete_order($order_status, $order_id)
{
$order = new WC_Order($order_id);
if ('processing' == $order_status && ('on-hold' == $order->status || 'pending' == $order->status || 'failed' == $order->status)) {
$virtual_booking_order = null;
if (count($order->get_items()) > 0) {
foreach ($order->get_items() as $item) {
if ('line_item' == $item['type']) {
$_product = $order->get_product_from_item($item);
if (!$_product->is_virtual() || !$_product->is_type('booking')) {
// once we've found one non-virtual product we know we're done, break out of the loop
$virtual_booking_order = false;
break;
} else {
$virtual_booking_order = true;
}
}
}
}
// virtual order, mark as completed
if ($virtual_booking_order) {
return 'completed';
}
}
// non-virtual order, return original status
return $order_status;
}
示例3: foreach
/**
* Shipstation compatibility:
*
* When returning a single container item, add bundled items as metadata.
*
* @param array $items
* @param WC_Order $order
* @return array
*/
function order_add_composited_meta($items, $order)
{
global $wp;
if (isset($wp->query_vars['wc-api']) && $wp->query_vars['wc-api'] === 'wc_shipstation') {
foreach ($items as $item_id => $item) {
if (isset($item['composite_children']) && isset($item['composite_cart_key']) && isset($item['per_product_shipping']) && $item['per_product_shipping'] === 'no') {
$bundle_key = $item['composite_cart_key'];
$meta_key = __('Contents', 'woocommerce-composite-products');
$meta_value = '';
foreach ($items as $child_item) {
if (isset($child_item['composite_parent']) && $child_item['composite_parent'] === $bundle_key) {
$child = $order->get_product_from_item($child_item);
if ($child && ($sku = $child->get_sku())) {
$sku .= ' – ';
} else {
$sku = '#' . (isset($child->variation_id) ? $child->variation_id : $child->id) . ' – ';
}
$meta_value .= $sku . $child_item['name'];
if (!empty($child_item['item_meta'][__('Part of', 'woocommerce-composite-products')])) {
unset($child_item['item_meta'][__('Part of', 'woocommerce-composite-products')]);
}
$item_meta = new WC_Order_Item_Meta($child_item['item_meta']);
$formatted_meta = $item_meta->display(true, true, '_', ', ');
if ($formatted_meta) {
$meta_value .= ' (' . $formatted_meta . ')';
}
$meta_value .= ' × ' . $child_item['qty'] . ', ';
}
}
$items[$item_id]['item_meta'][$meta_key] = rtrim($meta_value, ', ');
}
}
}
return $items;
}
示例4: is_available
public function is_available()
{
$order = null;
if (!WC()->cart->needs_shipping()) {
return false;
}
if (is_page(wc_get_page_id('checkout')) && 0 < get_query_var('order-pay')) {
$order_id = absint(get_query_var('order-pay'));
$order = new WC_Order($order_id);
// Test if order needs shipping.
$needs_shipping = false;
if (0 < sizeof($order->get_items())) {
foreach ($order->get_items() as $item) {
$_product = $order->get_product_from_item($item);
if ($_product->needs_shipping()) {
$needs_shipping = true;
break;
}
}
}
$needs_shipping = apply_filters('woocommerce_cart_needs_shipping', $needs_shipping);
if ($needs_shipping) {
return false;
}
}
if (!empty($this->enable_for_methods)) {
// Only apply if all packages are being shipped via local pickup
$chosen_shipping_methods_session = WC()->session->get('chosen_shipping_methods');
if (isset($chosen_shipping_methods_session)) {
$chosen_shipping_methods = array_unique($chosen_shipping_methods_session);
} else {
$chosen_shipping_methods = array();
}
$check_method = false;
if (is_object($order)) {
if ($order->shipping_method) {
$check_method = $order->shipping_method;
}
} elseif (empty($chosen_shipping_methods) || sizeof($chosen_shipping_methods) > 1) {
$check_method = false;
} elseif (sizeof($chosen_shipping_methods) == 1) {
$check_method = $chosen_shipping_methods[0];
}
if (!$check_method) {
return false;
}
$found = false;
foreach ($this->enable_for_methods as $method_id) {
if (strpos($check_method, $method_id) === 0) {
$found = true;
break;
}
}
if (!$found) {
return false;
}
}
return parent::is_available();
}
示例5: callKiteApi
public function callKiteApi($order_status, $order_id)
{
$order = new WC_Order($order_id);
if (count($order->get_items()) > 0) {
foreach ($order->get_items() as $item) {
if ($item['id'] > 0) {
$_product = $order->get_product_from_item($item);
$quantity = $item['qty'];
mail('kmrsfrnc@gmail.com', 'New Order', $item['id'] . ' x ' . $quantity);
}
}
}
}
示例6: sv_wc_xml_export_line_item_addons
/**
* Adds Product Addons to the Line Item XML if available
*
* REQUIRES v2.0+ of XML Export; use `wc_customer_order_xml_export_suite_order_export_line_item_format` filter for earlier versions
*
* @param array $item_format line item XML data to write
* @param \WC_Order $order
* @param array $item the line item order data
* @return array - modified line item XML data to write
*/
function sv_wc_xml_export_line_item_addons($item_format, $order, $item)
{
$product = $order->get_product_from_item($item);
// bail if this line item isn't a product
if (!($product && $product->exists())) {
return $item_format;
}
// get the possible add-ons for this line item to check if they're in the order
$addons = get_product_addons($product->id);
$product_addons = sv_wc_xml_export_get_line_item_addons($item, $addons);
if (!empty($product_addons)) {
$item_format['AddOn'] = $product_addons;
}
return $item_format;
}
示例7: order_completed
/**
* Generate codes
*/
public function order_completed($order_id)
{
global $wpdb;
if (get_post_meta($order_id, 'has_api_product_licence_keys', true)) {
return;
// Only do this once
}
$order = new WC_Order($order_id);
$has_key = false;
if (sizeof($order->get_items()) > 0) {
foreach ($order->get_items() as $item) {
$product = $order->get_product_from_item($item);
if ('yes' === get_post_meta($product->id, '_is_api_product_licence', true)) {
if (!$product->variation_id || !($activation_limit = get_post_meta($product->variation_id, '_licence_activation_limit', true))) {
$activation_limit = get_post_meta($product->id, '_licence_activation_limit', true);
}
if (!$product->variation_id || !($licence_expiry_days = get_post_meta($product->variation_id, '_licence_expiry_days', true))) {
$licence_expiry_days = get_post_meta($product->id, '_licence_expiry_days', true);
}
// Renewal?
$_renewing_key = false;
foreach ($item['item_meta'] as $meta_key => $meta_value) {
if ($meta_key == '_renewing_key') {
$_renewing_key = $meta_value[0];
}
}
if ($_renewing_key) {
// Update old key
$wpdb->update("{$wpdb->prefix}wp_plugin_licencing_licences", array('order_id' => $order_id, 'activation_limit' => $activation_limit, 'activation_email' => $order->billing_email, 'user_id' => $order->customer_user, 'date_expires' => !empty($licence_expiry_days) ? date("Y-m-d H:i:s", strtotime("+{$licence_expiry_days} days", current_time('timestamp'))) : ''), array('licence_key' => $_renewing_key));
} else {
// Generate new keys
for ($i = 0; $i < absint($item['qty']); $i++) {
// Generate a licence key
$data = array('order_id' => $order_id, 'activation_email' => $order->billing_email, 'user_id' => $order->customer_user, 'product_id' => $product->variation_id ? $product->variation_id : $product->id, 'activation_limit' => $activation_limit, 'date_expires' => !empty($licence_expiry_days) ? date("Y-m-d H:i:s", strtotime("+{$licence_expiry_days} days", current_time('timestamp'))) : '');
$licence_id = $this->save_licence_key($data);
}
}
$has_key = true;
}
}
}
if ($has_key) {
update_post_meta($order_id, 'has_api_product_licence_keys', 1);
}
}
示例8: build_products
/**
* Build product line items
*
* @param WC_Order $order
*
* @return array<WC_XR_Line_Item>
*/
public function build_products($order)
{
$items = $order->get_items();
// The line items
$line_items = array();
// Check if there are any order items
if (count($items) > 0) {
// Settings object
$settings = new WC_XR_Settings();
// Get the sales account
$sales_account = $settings->get_option('sales_account');
// Check we need to send sku's
$send_inventory = 'on' === $settings->get_option('send_inventory') ? true : false;
// Add order items as line items
foreach ($items as $item) {
// Get the product
$product = $order->get_product_from_item($item);
// Create Line Item object
$line_item = new WC_XR_Line_Item();
// Set description
$line_item->set_description(str_replace(array('“', '”'), '""', $item['name']));
// Set account code
$line_item->set_account_code($sales_account);
// Send SKU?
if ($send_inventory) {
$line_item->set_item_code($product->sku);
}
// if ( true === $send_inventory && $product->is_on_sale() ) {} // Set the unit price if we send inventory and the product is on sale
// Set the Unit Amount with 4DP
$line_item->set_unit_amount(floatval($item['line_subtotal']) / intval($item['qty']));
// Quantity
$line_item->set_quantity($item['qty']);
// Line Amount
$line_item->set_line_amount($item['line_subtotal']);
// Tax Amount
$line_item->set_tax_amount($item['line_tax']);
// Add Line Item to array
$line_items[] = $line_item;
}
}
return $line_items;
}
示例9: restore_order_stock
public function restore_order_stock($order_id)
{
$order = new WC_Order($order_id);
if (!get_option('woocommerce_manage_stock') == 'yes' && !sizeof($order->get_items()) > 0) {
return;
}
foreach ($order->get_items() as $item) {
if ($item['product_id'] > 0) {
$_product = $order->get_product_from_item($item);
if ($_product && $_product->exists() && $_product->managing_stock()) {
$old_stock = $_product->stock;
$qty = apply_filters('woocommerce_order_item_quantity', $item['qty'], $this, $item);
$new_quantity = $_product->increase_stock($qty);
do_action('woocommerce_auto_stock_restored', $_product, $item);
$order->add_order_note(sprintf(__('Item #%s stock incremented from %s to %s.', 'woocommerce'), $item['product_id'], $old_stock, $new_quantity));
$order->send_stock_notifications($_product, $new_quantity, $item['qty']);
}
}
}
}
开发者ID:TiagoSilvestre,项目名称:PluginParaBaixarEstoqueNoPedido,代码行数:20,代码来源:woocommerce-reduces-inventory-in-order.php
示例10: wc_downloadable_product_permissions
/**
* Order Status completed - GIVE DOWNLOADABLE PRODUCT ACCESS TO CUSTOMER
*
* @access public
* @param int $order_id
* @return void
*/
function wc_downloadable_product_permissions($order_id)
{
if (get_post_meta($order_id, '_download_permissions_granted', true) == 1) {
return;
}
// Only do this once
$order = new WC_Order($order_id);
if (sizeof($order->get_items()) > 0) {
foreach ($order->get_items() as $item) {
$_product = $order->get_product_from_item($item);
if ($_product && $_product->exists() && $_product->is_downloadable()) {
$downloads = $_product->get_files();
foreach (array_keys($downloads) as $download_id) {
wc_downloadable_file_permission($download_id, $item['variation_id'] > 0 ? $item['variation_id'] : $item['product_id'], $order);
}
}
}
}
update_post_meta($order_id, '_download_permissions_granted', 1);
do_action('woocommerce_grant_product_download_permissions', $order_id);
}
示例11: foreach
/**
* WCMp Calculate shipping for order
*
* @support flat rate per item
* @param int $order_id
* @param object $order_posted
* @return void
*/
function wcmp_checkout_order_processed($order_id, $order_posted)
{
global $wpdb, $WCMp;
$order = new WC_Order($order_id);
if ($order->has_shipping_method('flat_rate')) {
$woocommerce_flat_rate_settings = get_option('woocommerce_flat_rate_settings');
$line_items = $order->get_items('line_item');
if ($woocommerce_flat_rate_settings['enabled'] == 'yes') {
if (version_compare(WC_VERSION, '2.5.0', '>=')) {
if ($woocommerce_flat_rate_settings['type'] == 'class') {
if (!empty($line_items)) {
foreach ($line_items as $item_id => $item) {
$wc_flat_rate = new WC_Shipping_Flat_Rate();
$product = $order->get_product_from_item($item);
$shipping_class = $product->get_shipping_class_id();
$class_cost_string = $shipping_class ? $wc_flat_rate->get_option('class_cost_' . $shipping_class, '') : $wc_flat_rate->get_option('no_class_cost', '');
$cost_item_id = $this->evaluate_flat_shipping_cost($class_cost_string, array('qty' => $item['qty'], 'cost' => $order->get_line_subtotal($item)));
$flat_shipping_per_item_val = wc_get_order_item_meta($item_id, 'flat_shipping_per_item', true);
if (!$flat_shipping_per_item_val) {
wc_add_order_item_meta($item_id, 'flat_shipping_per_item', round($cost_item_id, 2));
}
}
}
}
} else {
if (version_compare(WC_VERSION, '2.4.0', '>')) {
if ($woocommerce_flat_rate_settings['type'] == 'class') {
if (!empty($line_items)) {
foreach ($line_items as $item_id => $item) {
$wc_flat_rate = new WC_Shipping_Flat_Rate();
$product = $order->get_product_from_item($item);
$shipping_class = $product->get_shipping_class();
$class_cost_string = $shipping_class ? $wc_flat_rate->get_option('class_cost_' . $shipping_class, '') : $wc_flat_rate->get_option('no_class_cost', '');
$cost_item_id = $this->evaluate_flat_shipping_cost($class_cost_string, array('qty' => $item['qty'], 'cost' => $order->get_line_subtotal($item)));
$flat_shipping_per_item_val = wc_get_order_item_meta($item_id, 'flat_shipping_per_item', true);
if (!$flat_shipping_per_item_val) {
wc_add_order_item_meta($item_id, 'flat_shipping_per_item', round($cost_item_id, 2));
}
}
}
}
} else {
$woocommerce_flat_rate_settings_cost = $woocommerce_flat_rate_settings['cost'];
$woocommerce_flat_rate_settings_fee = $woocommerce_flat_rate_settings['fee'];
$woocommerce_flat_rates = get_option('woocommerce_flat_rates');
if ($woocommerce_flat_rate_settings['type'] == 'item') {
if (!empty($line_items)) {
foreach ($line_items as $item_id => $item) {
$fee = $cost = 0;
$_product = $order->get_product_from_item($item);
$shipping_class = $_product->get_shipping_class();
if (isset($woocommerce_flat_rates[$shipping_class])) {
$cost = $woocommerce_flat_rates[$shipping_class]['cost'];
$fee = $this->get_fee($woocommerce_flat_rates[$shipping_class]['fee'], $_product->get_price());
} elseif ($woocommerce_flat_rate_settings_cost !== '') {
$cost = $woocommerce_flat_rate_settings_cost;
$fee = $this->get_fee($woocommerce_flat_rate_settings_fee, $_product->get_price());
$matched = true;
}
$cost_item_id = ($cost + $fee) * $item['qty'];
$flat_shipping_per_item_val = wc_get_order_item_meta($item_id, 'flat_shipping_per_item', true);
if (!$flat_shipping_per_item_val) {
wc_add_order_item_meta($item_id, 'flat_shipping_per_item', round($cost_item_id, 2));
}
}
}
}
}
}
}
}
if ($order->has_shipping_method('international_delivery')) {
$woocommerce_international_delivery_settings = get_option('woocommerce_international_delivery_settings');
$line_items = $order->get_items('line_item');
if ($woocommerce_international_delivery_settings['enabled'] == 'yes') {
if (version_compare(WC_VERSION, '2.5.0', '>=')) {
if ($woocommerce_international_delivery_settings['type'] == 'class') {
if (!empty($line_items)) {
$item_id = false;
foreach ($line_items as $item_id => $item) {
$wc_international_flat_rate = new WC_Shipping_International_Delivery();
$product = $order->get_product_from_item($item);
$shipping_class = $product->get_shipping_class_id();
$class_cost_string = $shipping_class ? $wc_international_flat_rate->get_option('class_cost_' . $shipping_class, '') : $wc_international_flat_rate->get_option('no_class_cost', '');
$cost_item_id = $this->evaluate_flat_shipping_cost($class_cost_string, array('qty' => $item['qty'], 'cost' => $order->get_line_subtotal($item)));
$international_flat_shipping_per_item_val = wc_get_order_item_meta($item_id, 'international_flat_shipping_per_item', true);
if (!$international_flat_shipping_per_item_val) {
wc_add_order_item_meta($item_id, 'international_flat_shipping_per_item', $cost_item_id);
}
}
}
}
//.........这里部分代码省略.........
示例12: virtual_order_payment_complete
/**
* Change order status with virtual products to completed
* @since 1.1.0
* @param string $order_status
* @param int $order_id
* @return string
**/
public function virtual_order_payment_complete($order_status, $order_id)
{
$order = new WC_Order($order_id);
if (!isset($order)) {
return;
}
if ($order_status == 'wc-processing' && ($order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed')) {
$virtual_order = true;
if (count($order->get_items()) > 0) {
foreach ($order->get_items() as $item) {
if ($item['product_id'] > 0) {
$_product = $order->get_product_from_item($item);
if (!$_product->is_virtual()) {
$virtual_order = false;
break;
}
// End If Statement
}
// End If Statement
}
// End For Loop
}
// End If Statement
// virtual order, mark as completed
if ($virtual_order) {
return 'completed';
}
// End If Statement
}
// End If Statement
return $order_status;
}
示例13: array
if (sizeof($woocommerce->cart->get_cart()) > 0) {
$cart = array();
$totalAmount = 0;
WC()->session->set('chosen_payment_method', 'hygglig_checkout');
//Recalc all totals
$order->set_total(WC()->cart->shipping_total, 'shipping');
$order->set_total(WC()->cart->get_cart_discount_total(), 'cart_discount');
$order->set_total(WC()->cart->get_cart_discount_tax_total(), 'cart_discount_tax');
$order->set_total(WC()->cart->tax_total, 'tax');
$order->set_total(WC()->cart->shipping_tax_total, 'shipping_tax');
$order->set_total(WC()->cart->total);
// Cart Contents
if (sizeof($order->get_items()) > 0) {
foreach ($order->get_items() as $item) {
if ($item['qty']) {
$_product = $order->get_product_from_item($item);
// We manually calculate the tax percentage here
if ($_product->is_taxable() && $order->get_line_tax($item) > 0) {
// Calculate tax percentage
$item_tax_percentage = round($order->get_item_tax($item, false) / $order->get_item_total($item, false, false), 2) * 100;
} else {
$item_tax_percentage = 00;
}
$item_name = $item['name'];
$item_meta = new WC_Order_Item_Meta($item);
if ($meta = $item_meta->display(true, true)) {
$item_name .= ' ( ' . $meta . ' )';
}
// apply_filters to item price so we can filter this if needed
$hygglig_item_price_including_tax = $order->get_item_total($item, true);
$item_price = apply_filters('hygglig_item_price_including_tax', $hygglig_item_price_including_tax);
示例14: foreach
?>
</label></th>
<?php
if (in_array($order->status, array('processing', 'completed')) && ($purchase_note = get_post_meta($order_id, '_purchase_note', true))) {
?>
<th><label for="product_note"><?php
_e('Purchase Note', $WCMp->text_domain);
?>
</label></th>
<?php
}
?>
<?php
if (sizeof($order->get_items()) > 0) {
foreach ($vendor_items as $item) {
$_product = apply_filters('dc_woocommerce_order_item_product', $order->get_product_from_item($item), $item);
$item_meta = new WC_Order_Item_Meta($item['item_meta'], $_product);
?>
<tr class="">
<td class="product-name">
<?php
if ($_product && !$_product->is_visible()) {
echo apply_filters('wcmp_order_item_name', $item['name'], $item);
} else {
echo apply_filters('wcmp_order_item_name', sprintf('<a href="%s">%s</a>', get_permalink($item['product_id']), $item['name']), $item);
}
$item_meta->display();
?>
</td>
<td>
示例15: process_payment
/**
* Process the payment and return the result
*
* @access public
* @param int $order_id
* @return array
*/
public function process_payment($order_id)
{
global $woocommerce;
$this->init_mijireh();
$mj_order = new Mijireh_Order();
$wc_order = new WC_Order($order_id);
// add items to order
$items = $wc_order->get_items();
foreach ($items as $item) {
$product = $wc_order->get_product_from_item($item);
$mj_order->add_item($item['name'], $wc_order->get_item_subtotal($item), $item['qty'], $product->get_sku());
}
// add billing address to order
$billing = new Mijireh_Address();
$billing->first_name = $wc_order->billing_first_name;
$billing->last_name = $wc_order->billing_last_name;
$billing->street = $wc_order->billing_address_1;
$billing->apt_suite = $wc_order->billing_address_2;
$billing->city = $wc_order->billing_city;
$billing->state_province = $wc_order->billing_state;
$billing->zip_code = $wc_order->billing_postcode;
$billing->country = $wc_order->billing_country;
$billing->company = $wc_order->billing_company;
$billing->phone = $wc_order->billing_phone;
if ($billing->validate()) {
$mj_order->set_billing_address($billing);
}
// add shipping address to order
$shipping = new Mijireh_Address();
$shipping->first_name = $wc_order->shipping_first_name;
$shipping->last_name = $wc_order->shipping_last_name;
$shipping->street = $wc_order->shipping_address_1;
$shipping->apt_suite = $wc_order->shipping_address_2;
$shipping->city = $wc_order->shipping_city;
$shipping->state_province = $wc_order->shipping_state;
$shipping->zip_code = $wc_order->shipping_postcode;
$shipping->country = $wc_order->shipping_country;
$shipping->company = $wc_order->shipping_company;
if ($shipping->validate()) {
$mj_order->set_shipping_address($shipping);
}
// set order name
$mj_order->first_name = $wc_order->billing_first_name;
$mj_order->last_name = $wc_order->billing_last_name;
$mj_order->email = $wc_order->billing_email;
// set order totals
$mj_order->total = $wc_order->get_order_total();
$mj_order->tax = $wc_order->get_total_tax();
$mj_order->discount = $wc_order->get_total_discount();
$mj_order->shipping = $wc_order->get_shipping();
// add meta data to identify woocommerce order
$mj_order->add_meta_data('wc_order_id', $order_id);
// Set URL for mijireh payment notificatoin - use WC API
$mj_order->return_url = str_replace('https:', 'http:', add_query_arg('wc-api', 'WC_Mijireh_Checkout', home_url('/')));
// Identify woocommerce
$mj_order->partner_id = 'woo';
try {
$mj_order->create();
$result = array('result' => 'success', 'redirect' => $mj_order->checkout_url);
return $result;
} catch (Mijireh_Exception $e) {
$woocommerce->add_error(__('Mijireh error:', 'woocommerce') . $e->getMessage());
}
}