当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Order::get_total_shipping方法代码示例

本文整理汇总了PHP中WC_Order::get_total_shipping方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::get_total_shipping方法的具体用法?PHP WC_Order::get_total_shipping怎么用?PHP WC_Order::get_total_shipping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Order的用法示例。


在下文中一共展示了WC_Order::get_total_shipping方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_total_shipping

 /**
  * Returns the shipping total, in order currency.
  *
  * @since WooCommerce 2.1.
  */
 public function get_total_shipping()
 {
     // If parent has this method, let's use it. It means we are in WooCommerce 2.1+
     if (method_exists(get_parent_class($this), __FUNCTION__)) {
         return parent::get_total_shipping();
     }
     // Fall back to legacy method in WooCommerce 2.0 and earlier
     return $this->get_shipping();
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:14,代码来源:wc-aelia-order.php

示例2: get_shipping_info

 /**
  * @param WC_Order $order
  *
  * @return array
  */
 public static function get_shipping_info($order)
 {
     $total = $order->get_total_shipping();
     if ($total) {
         $tax_rate = 100 * $order->order_shipping_tax / $total;
     } else {
         $tax_rate = 0;
     }
     $serializer = array_merge(self::get_address($order, 'shipping'), array('price' => Aplazame_Filters::decimals($total), 'tax_rate' => Aplazame_Filters::decimals($tax_rate), 'name' => $order->get_shipping_method()));
     return $serializer;
 }
开发者ID:aplazame,项目名称:woocommerce,代码行数:16,代码来源:Serializers.php

示例3: get_komoju_args

 /**
  * Get Komoju Args for passing to Komoju hosted page
  *
  * @param WC_Order $order
  * @return array
  */
 protected function get_komoju_args($order, $method)
 {
     WC_Gateway_Komoju::log('Generating payment form for order ' . $order->get_order_number() . '. Notify URL: ' . $this->notify_url);
     $params = array("transaction[amount]" => $order->get_subtotal() + $order->get_total_shipping(), "transaction[currency]" => get_woocommerce_currency(), "transaction[customer][email]" => $order->billing_email, "transaction[customer][phone]" => $order->billing_phone, "transaction[customer][given_name]" => $order->billing_first_name, "transaction[customer][family_name]" => $order->billing_last_name, "transaction[external_order_num]" => $this->gateway->get_option('invoice_prefix') . $order->get_order_number() . '-' . $this->request_id, "transaction[return_url]" => $this->gateway->get_return_url($order), "transaction[cancel_url]" => $order->get_cancel_order_url_raw(), "transaction[callback_url]" => $this->notify_url, "transaction[tax]" => strlen($order->get_total_tax()) == 0 ? 0 : $order->get_total_tax(), "timestamp" => time());
     WC_Gateway_Komoju::log('Raw parametres: ' . print_r($params, true));
     $qs_params = array();
     foreach ($params as $key => $val) {
         $qs_params[] = urlencode($key) . '=' . urlencode($val);
     }
     sort($qs_params);
     $query_string = implode('&', $qs_params);
     $url = $this->Komoju_endpoint . $method . '/new' . '?' . $query_string;
     $hmac = hash_hmac('sha256', $url, $this->gateway->secretKey);
     $query_string .= '&hmac=' . $hmac;
     return $query_string;
 }
开发者ID:komoju,项目名称:komoju-woocommerce,代码行数:22,代码来源:class-wc-gateway-komoju-request.php

示例4: getRequestData

/**
 * Bundle and format the order information
 * @param WC_Order $order
 * Send as much information about the order as possible to Conekta
 */
function getRequestData($order)
{
    if ($order and $order != null) {
        // custom fields
        $custom_fields = array("total_discount" => (double) $order->get_total_discount() * 100);
        // $user_id = $order->get_user_id();
        // $is_paying_customer = false;
        $order_coupons = $order->get_used_coupons();
        // if ($user_id != 0) {
        //     $custom_fields = array_merge($custom_fields, array(
        //         "is_paying_customer" => is_paying_customer($user_id)
        //     ));
        // }
        if (count($order_coupons) > 0) {
            $custom_fields = array_merge($custom_fields, array("coupon_code" => $order_coupons[0]));
        }
        return array("amount" => (double) $order->get_total() * 100, "token" => $_POST['conektaToken'], "shipping_method" => $order->get_shipping_method(), "shipping_carrier" => $order->get_shipping_method(), "shipping_cost" => (double) $order->get_total_shipping() * 100, "monthly_installments" => (int) $_POST['monthly_installments'], "currency" => strtolower(get_woocommerce_currency()), "description" => sprintf("Charge for %s", $order->billing_email), "card" => array_merge(array("name" => sprintf("%s %s", $order->billing_first_name, $order->billing_last_name), "address_line1" => $order->billing_address_1, "address_line2" => $order->billing_address_2, "billing_company" => $order->billing_company, "phone" => $order->billing_phone, "email" => $order->billing_email, "address_city" => $order->billing_city, "address_zip" => $order->billing_postcode, "address_state" => $order->billing_state, "address_country" => $order->billing_country, "shipping_address_line1" => $order->shipping_address_1, "shipping_address_line2" => $order->shipping_address_2, "shipping_phone" => $order->shipping_phone, "shipping_email" => $order->shipping_email, "shipping_address_city" => $order->shipping_city, "shipping_address_zip" => $order->shipping_postcode, "shipping_address_state" => $order->shipping_state, "shipping_address_country" => $order->shipping_country), $custom_fields));
    }
    return false;
}
开发者ID:pcuervo,项目名称:wp-yolcan,代码行数:25,代码来源:conekta_gateway_helper.php

示例5: dokan_sync_order_table

/**
 * Insert a order in sync table once a order is created
 *
 * @global object $wpdb
 * @param int $order_id
 * @since 2.4
 */
function dokan_sync_order_table($order_id)
{
    global $wpdb;
    $order = new WC_Order($order_id);
    $seller_id = dokan_get_seller_id_by_order($order_id);
    $percentage = dokan_get_seller_percentage($seller_id);
    //Total calculation
    $order_total = $order->get_total();
    if ($total_refunded = $order->get_total_refunded()) {
        $order_total = $order_total - $total_refunded;
    }
    //Shipping calculation
    $order_shipping = $order->get_total_shipping();
    foreach ($order->get_items() as $item) {
        $total_shipping_refunded = 0;
        if ($shipping_refunded = $order->get_total_refunded_for_item($item['product_id'], 'shipping')) {
            $total_shipping_refunded += $shipping_refunded;
        }
    }
    $order_shipping = $order_shipping - $total_shipping_refunded;
    //Tax calculation
    $order_tax = $order->get_total_tax();
    if ($tax_refunded = $order->get_total_tax_refunded()) {
        $order_tax = $order_tax - $tax_refunded;
    }
    $extra_cost = $order_shipping + $order_tax;
    $order_cost = $order_total - $extra_cost;
    $order_status = $order->post_status;
    $net_amount = $order_cost * $percentage / 100 + $extra_cost;
    $net_amount = apply_filters('dokan_sync_order_net_amount', $net_amount, $order);
    $wpdb->insert($wpdb->prefix . 'dokan_orders', array('order_id' => $order_id, 'seller_id' => $seller_id, 'order_total' => $order_total, 'net_amount' => $net_amount, 'order_status' => $order_status), array('%d', '%d', '%f', '%f', '%s'));
}
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:39,代码来源:order-functions.php

示例6: array

                $product_id = $item['product_id'];
                $term_list = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));
                $cat_id = (int) $term_list[0];
                $category = get_term($cat_id, 'product_cat');
                $items[$i]['name'] = $item['name'];
                $items[$i]['quantity'] = $item['qty'];
                $items[$i]['sku'] = $product->get_sku();
                $items[$i]['price'] = $product->get_price();
                $items[$i]['category'] = $category->name;
                $product_variation_id = $item['variation_id'];
                // etc
                $i++;
            }
            $amount = $order->get_total();
            $affliation = 'Order ' . $order_id . ' details';
            $order_shipping_total = $order->get_total_shipping();
            $order_cart_tax = $order->get_cart_tax();
            //echo '<pre>'; print_r($order);
            // Transaction Data
            $trans = array('id' => $order_id, 'affiliation' => $affliation, 'revenue' => $amount, 'shipping' => $order_shipping_total, 'tax' => $order_cart_tax);
            // Function to return the JavaScript representation of a TransactionData object.
            function getTransactionJs(&$trans)
            {
                return <<<HTML
ga('ecommerce:addTransaction', {
  'id': '{$trans['id']}',
  'affiliation': '{$trans['affiliation']}',
  'revenue': '{$trans['revenue']}',
  'shipping': '{$trans['shipping']}',
  'tax': '{$trans['tax']}'
});
开发者ID:WP-Panda,项目名称:allergenics,代码行数:31,代码来源:step4.php

示例7: array

 /**
  * Charge Payment
  * Method ini digunakan untuk mendapatkan link halaman pembayaran Veritrans
  * dengan mengirimkan JSON yang berisi data transaksi
  */
 function charge_payment($order_id)
 {
     global $woocommerce;
     $order_items = array();
     $cart = $woocommerce->cart;
     $order = new WC_Order($order_id);
     Veritrans_Config::$isProduction = $this->environment == 'production' ? true : false;
     Veritrans_Config::$serverKey = Veritrans_Config::$isProduction ? $this->server_key_v2_production : $this->server_key_v2_sandbox;
     Veritrans_Config::$is3ds = $this->enable_3d_secure == 'yes' ? true : false;
     Veritrans_Config::$isSanitized = $this->enable_sanitization == 'yes' ? true : false;
     $params = array('transaction_details' => array('order_id' => $order_id, 'gross_amount' => 0), 'vtweb' => array());
     $enabled_payments = array();
     if ($this->enable_credit_card == 'yes') {
         $enabled_payments[] = 'credit_card';
     }
     if ($this->enable_mandiri_clickpay == 'yes') {
         $enabled_payments[] = 'mandiri_clickpay';
     }
     if ($this->enable_cimb_clicks == 'yes') {
         $enabled_payments[] = 'cimb_clicks';
     }
     if ($this->enable_permata_va == 'yes') {
         $enabled_payments[] = 'bank_transfer';
     }
     if ($this->enable_bri_epay == 'yes') {
         $enabled_payments[] = 'bri_epay';
     }
     if ($this->enable_telkomsel_cash == 'yes') {
         $enabled_payments[] = 'telkomsel_cash';
     }
     if ($this->enable_xl_tunai == 'yes') {
         $enabled_payments[] = 'xl_tunai';
     }
     if ($this->enable_mandiri_bill == 'yes') {
         $enabled_payments[] = 'echannel';
     }
     if ($this->enable_bbmmoney == 'yes') {
         $enabled_payments[] = 'bbm_money';
     }
     if ($this->enable_indomaret == 'yes') {
         $enabled_payments[] = 'cstore';
     }
     if ($this->enable_indosat_dompetku == 'yes') {
         $enabled_payments[] = 'indosat_dompetku';
     }
     if ($this->enable_mandiri_ecash == 'yes') {
         $enabled_payments[] = 'mandiri_ecash';
     }
     $params['vtweb']['enabled_payments'] = $enabled_payments;
     $customer_details = array();
     $customer_details['first_name'] = $order->billing_first_name;
     $customer_details['last_name'] = $order->billing_last_name;
     $customer_details['email'] = $order->billing_email;
     $customer_details['phone'] = $order->billing_phone;
     $billing_address = array();
     $billing_address['first_name'] = $order->billing_first_name;
     $billing_address['last_name'] = $order->billing_last_name;
     $billing_address['address'] = $order->billing_address_1;
     $billing_address['city'] = $order->billing_city;
     $billing_address['postal_code'] = $order->billing_postcode;
     $billing_address['phone'] = $order->billing_phone;
     $billing_address['country_code'] = strlen($this->convert_country_code($order->billing_country) != 3) ? 'IDN' : $this->convert_country_code($order->billing_country);
     $customer_details['billing_address'] = $billing_address;
     $customer_details['shipping_address'] = $billing_address;
     if (isset($_POST['ship_to_different_address'])) {
         $shipping_address = array();
         $shipping_address['first_name'] = $order->shipping_first_name;
         $shipping_address['last_name'] = $order->shipping_last_name;
         $shipping_address['address'] = $order->shipping_address_1;
         $shipping_address['city'] = $order->shipping_city;
         $shipping_address['postal_code'] = $order->shipping_postcode;
         $shipping_address['phone'] = $order->billing_phone;
         $shipping_address['country_code'] = strlen($this->convert_country_code($order->shipping_country) != 3) ? 'IDN' : $this->convert_country_code($order->billing_country);
         $customer_details['shipping_address'] = $shipping_address;
     }
     $params['customer_details'] = $customer_details;
     //error_log(print_r($params,true));
     $items = array();
     if (sizeof($order->get_items()) > 0) {
         foreach ($order->get_items() as $item) {
             if ($item['qty']) {
                 $product = $order->get_product_from_item($item);
                 $veritrans_item = array();
                 $veritrans_item['id'] = $item['product_id'];
                 $veritrans_item['price'] = $order->get_item_subtotal($item, false);
                 $veritrans_item['quantity'] = $item['qty'];
                 $veritrans_item['name'] = $item['name'];
                 $items[] = $veritrans_item;
             }
         }
     }
     // Shipping fee
     if ($order->get_total_shipping() > 0) {
         $items[] = array('id' => 'shippingfee', 'price' => $order->get_total_shipping(), 'quantity' => 1, 'name' => 'Shipping Fee');
     }
//.........这里部分代码省略.........
开发者ID:rizdaprasetya,项目名称:veritrans-woocommerce,代码行数:101,代码来源:class.veritrans-gateway.php

示例8: array

 function charge_payment($order_id)
 {
     global $woocommerce;
     $order_items = array();
     $order = new WC_Order($order_id);
     MEOWallet_Config::$isProduction = $this->environment == 'production' ? TRUE : FALSE;
     MEOWallet_Config::$apikey = MEOWallet_Config::$isProduction ? $this->apikey_live : $this->apikey_sandbox;
     //MEOWallet_Config::$isTuned = 'yes';
     $params = array('payment' => array('client' => array('name' => $order->billing_first_name . ' ' . $order->billing_last_name, 'email' => $_POST['billing_email'], 'address' => array('country' => $_POST['billing_country'], 'address' => $_POST['billing_address_1'], 'city' => $_POST['billing_city'], 'postalcode' => $_POST['billing_postcode'])), 'amount' => $order->get_total(), 'currency' => 'EUR', 'items' => $items, 'url_confirm' => get_permalink(woocommerce_get_page_id('shop')) . '?' . $post_result_array->id, 'url_cancel' => get_permalink(woocommerce_get_page_id('shop')) . '?' . $post_result_array->id));
     $client_details = array();
     $client_details['name'] = $_POST['billing_first_name'] . ' ' . $_POST['billing_last_name'];
     $client_details['email'] = $_POST['billing_email'];
     //$client_details['address'] = $client_address;
     $client_address = array();
     $client_address['country'] = $_POST['billing_country'];
     $client_address['address'] = $_POST['billing_address_1'];
     $client_address['city'] = $_POST['billing_city'];
     $client_address['postalcode'] = $_POST['billing_postcode'];
     //$params['payment']['client'] = $client_details;
     //$params['payment']['client']['address'] = $client_address;
     $items = array();
     if (sizeof($order->get_items()) > 0) {
         foreach ($order->get_items() as $item) {
             if ($item['qty']) {
                 $product = $order->get_product_from_item($item);
                 $client_items = array();
                 $client_items['client']['id'] = $item['id'];
                 $client_item['client']['name'] = $item['name'];
                 $client_items['client']['description'] = $item['name'];
                 $client_item['client']['qt'] = $item['qty'];
                 $items['client'][] = $client_items;
             }
         }
     }
     if ($order->get_total_shipping() > 0) {
         $items[] = array('id' => 'shippingfee', 'price' => $order->get_total_shipping(), 'quantity' => 1, 'name' => 'Shipping Fee');
     }
     if ($order->get_total_tax() > 0) {
         $items[] = array('id' => 'taxfee', 'price' => $order->get_total_tax(), 'quantity' => 1, 'name' => 'Tax');
     }
     if ($order->get_order_discount() > 0) {
         $items[] = array('id' => 'totaldiscount', 'price' => $order->get_total_discount() * -1, 'quantity' => 1, 'name' => 'Total Discount');
     }
     if (sizeof($order->get_fees()) > 0) {
         $fees = $order->get_fees();
         $i = 0;
         foreach ($fees as $item) {
             $items[] = array('id' => 'itemfee' . $i, 'price' => $item['line_total'], 'quantity' => 1, 'name' => $item['name']);
             $i++;
         }
     }
     //$params['client']['amount'] = $order->get_total();
     //if (get_woocommerce_currency() != 'EUR'){
     //	foreach ($items as &$item){
     //		$item['price'] = $item['price'] * $this->to_euro_rate;
     //	}
     //	unset($item);
     //	$params['payment']['amount'] *= $this->to_euro_rate;
     //}
     //$params['payment']['items'] = $items;
     //$woocommerce->cart->empty_cart();
     return MEOWallet_Checkout::getRedirectionUrl($params);
 }
开发者ID:jquiterio,项目名称:meowallet,代码行数:63,代码来源:meowallet.php

示例9: formOrderArray

 protected function formOrderArray(\WC_Order $order)
 {
     $totalFees = 0;
     foreach ($order->get_fees() as $fee) {
         $totalFees += $fee['line_total'];
     }
     $this->order = array('order_id' => $order->id, 'revenue' => round($order->order_total - $totalFees, wc_get_price_decimals()), 'shipping' => $order->get_total_shipping(), 'tax' => $order->get_total_tax());
     return $this->order;
 }
开发者ID:panvagenas,项目名称:skroutz-analytics-for-woocommerce,代码行数:9,代码来源:SkroutzAnalytics.php

示例10: get_order_data

 /**
  * Get the order data for the given ID.
  *
  * @since  2.5.0
  * @param  WC_Order $order The order instance
  * @return array
  */
 protected function get_order_data($order)
 {
     $order_post = get_post($order->id);
     $dp = wc_get_price_decimals();
     $order_data = array('id' => $order->id, 'order_number' => $order->get_order_number(), 'created_at' => $this->format_datetime($order_post->post_date_gmt), 'updated_at' => $this->format_datetime($order_post->post_modified_gmt), 'completed_at' => $this->format_datetime($order->completed_date, true), 'status' => $order->get_status(), 'currency' => $order->get_order_currency(), 'total' => wc_format_decimal($order->get_total(), $dp), 'subtotal' => wc_format_decimal($order->get_subtotal(), $dp), 'total_line_items_quantity' => $order->get_item_count(), 'total_tax' => wc_format_decimal($order->get_total_tax(), $dp), 'total_shipping' => wc_format_decimal($order->get_total_shipping(), $dp), 'cart_tax' => wc_format_decimal($order->get_cart_tax(), $dp), 'shipping_tax' => wc_format_decimal($order->get_shipping_tax(), $dp), 'total_discount' => wc_format_decimal($order->get_total_discount(), $dp), 'shipping_methods' => $order->get_shipping_method(), 'payment_details' => array('method_id' => $order->payment_method, 'method_title' => $order->payment_method_title, 'paid' => isset($order->paid_date)), 'billing_address' => array('first_name' => $order->billing_first_name, 'last_name' => $order->billing_last_name, 'company' => $order->billing_company, 'address_1' => $order->billing_address_1, 'address_2' => $order->billing_address_2, 'city' => $order->billing_city, 'state' => $order->billing_state, 'postcode' => $order->billing_postcode, 'country' => $order->billing_country, 'email' => $order->billing_email, 'phone' => $order->billing_phone), 'shipping_address' => array('first_name' => $order->shipping_first_name, 'last_name' => $order->shipping_last_name, 'company' => $order->shipping_company, 'address_1' => $order->shipping_address_1, 'address_2' => $order->shipping_address_2, 'city' => $order->shipping_city, 'state' => $order->shipping_state, 'postcode' => $order->shipping_postcode, 'country' => $order->shipping_country), 'note' => $order->customer_note, 'customer_ip' => $order->customer_ip_address, 'customer_user_agent' => $order->customer_user_agent, 'customer_id' => $order->get_user_id(), 'view_order_url' => $order->get_view_order_url(), 'line_items' => array(), 'shipping_lines' => array(), 'tax_lines' => array(), 'fee_lines' => array(), 'coupon_lines' => array());
     // add line items
     foreach ($order->get_items() as $item_id => $item) {
         $product = $order->get_product_from_item($item);
         $product_id = null;
         $product_sku = null;
         // Check if the product exists.
         if (is_object($product)) {
             $product_id = isset($product->variation_id) ? $product->variation_id : $product->id;
             $product_sku = $product->get_sku();
         }
         $meta = new WC_Order_Item_Meta($item, $product);
         $item_meta = array();
         foreach ($meta->get_formatted(null) as $meta_key => $formatted_meta) {
             $item_meta[] = array('key' => $meta_key, 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value']);
         }
         $order_data['line_items'][] = array('id' => $item_id, 'subtotal' => wc_format_decimal($order->get_line_subtotal($item, false, false), $dp), 'subtotal_tax' => wc_format_decimal($item['line_subtotal_tax'], $dp), 'total' => wc_format_decimal($order->get_line_total($item, false, false), $dp), 'total_tax' => wc_format_decimal($item['line_tax'], $dp), 'price' => wc_format_decimal($order->get_item_total($item, false, false), $dp), 'quantity' => wc_stock_amount($item['qty']), 'tax_class' => !empty($item['tax_class']) ? $item['tax_class'] : null, 'name' => $item['name'], 'product_id' => $product_id, 'sku' => $product_sku, 'meta' => $item_meta);
     }
     // Add shipping.
     foreach ($order->get_shipping_methods() as $shipping_item_id => $shipping_item) {
         $order_data['shipping_lines'][] = array('id' => $shipping_item_id, 'method_id' => $shipping_item['method_id'], 'method_title' => $shipping_item['name'], 'total' => wc_format_decimal($shipping_item['cost'], $dp));
     }
     // Add taxes.
     foreach ($order->get_tax_totals() as $tax_code => $tax) {
         $order_data['tax_lines'][] = array('id' => $tax->id, 'rate_id' => $tax->rate_id, 'code' => $tax_code, 'title' => $tax->label, 'total' => wc_format_decimal($tax->amount, $dp), 'compound' => (bool) $tax->is_compound);
     }
     // Add fees.
     foreach ($order->get_fees() as $fee_item_id => $fee_item) {
         $order_data['fee_lines'][] = array('id' => $fee_item_id, 'title' => $fee_item['name'], 'tax_class' => !empty($fee_item['tax_class']) ? $fee_item['tax_class'] : null, 'total' => wc_format_decimal($order->get_line_total($fee_item), $dp), 'total_tax' => wc_format_decimal($order->get_line_tax($fee_item), $dp));
     }
     // Add coupons.
     foreach ($order->get_items('coupon') as $coupon_item_id => $coupon_item) {
         $order_data['coupon_lines'][] = array('id' => $coupon_item_id, 'code' => $coupon_item['name'], 'amount' => wc_format_decimal($coupon_item['discount_amount'], $dp));
     }
     $order_data = apply_filters('woocommerce_cli_order_data', $order_data);
     return $this->flatten_array($order_data);
 }
开发者ID:jgcopple,项目名称:drgaryschwantz,代码行数:48,代码来源:class-wc-cli-order.php

示例11: process_refund

 public function process_refund($order_id, $amount = NULL, $reason = '')
 {
     global $woocommerce;
     $wc_order = new WC_Order($order_id);
     $trx_id = get_post_meta($order_id, '_transaction_id', true);
     $trx_metas = get_post_meta($order_id, '_' . $order_id . '_' . $trx_id . '_metas', true);
     $last_four = isset($trx_metas['account_number']) ? esc_attr($trx_metas['account_number']) : '';
     $refund = new AuthorizeNetAIM();
     $customer = (object) array();
     $customer->first_name = $wc_order->billing_first_name;
     $customer->last_name = $wc_order->billing_last_name;
     $customer->company = $wc_order->billing_company;
     $customer->address = $wc_order->billing_address_1 . ' ' . $wc_order->billing_address_2;
     $customer->city = $wc_order->billing_city;
     $customer->state = $wc_order->billing_state;
     $customer->zip = $wc_order->billing_postcode;
     $customer->country = $wc_order->billing_country;
     $customer->phone = $wc_order->billing_phone;
     $customer->email = $wc_order->billing_email;
     $customer->cust_id = $wc_order->user_id;
     $customer->invoice_num = $wc_order->get_order_number();
     $customer->description = get_bloginfo('blogname') . ' Order #' . $wc_order->get_order_number();
     $customer->ship_to_first_name = $wc_order->shipping_first_name;
     $customer->ship_to_last_name = $wc_order->shipping_last_name;
     $customer->ship_to_company = $wc_order->shipping_company;
     $customer->ship_to_address = $wc_order->shipping_address_1 . ' ' . $wc_order->shipping_address_2;
     $customer->ship_to_city = $wc_order->shipping_city;
     $customer->ship_to_state = $wc_order->shipping_state;
     $customer->ship_to_zip = $wc_order->shipping_postcode;
     $customer->ship_to_country = $wc_order->shipping_country;
     $customer->delim_char = '|';
     $customer->encap_char = '';
     $customer->customer_ip = $this->get_client_ip();
     $customer->tax = $wc_order->get_total_tax();
     $customer->freight = $wc_order->get_total_shipping();
     $customer->header_email_receipt = 'Refund From ' . get_bloginfo('blogname') . ' ' . $reason;
     $customer->footer_email_receipt = 'Thank you for Using ' . get_bloginfo('blogname');
     $refund->setFields($customer);
     $refundtrx = $refund->credit($trx_id, $amount, $last_four);
     if (1 == $refundtrx->approved) {
         $wc_order->add_order_note(__($refundtrx->response_reason_text . 'on' . date("d-m-Y h:i:s e") . 'with Transaction ID = ' . $refundtrx->transaction_id . ' using ' . strtoupper($refundtrx->transaction_type) . ' and authorization code ' . $refundtrx->authorization_code, 'woocommerce'));
         if ($wc_order->order_total == $amount) {
             $wc_order->update_status('wc-refunded');
         }
         return true;
     } else {
         if (2 == $refundtrx->response_subcode || 54 == $refundtrx->response_reason_code) {
             $refundtrx = $refund->void($trx_id);
             if (1 == $refundtrx->approved) {
                 $wc_order->add_order_note(__($refundtrx->response_reason_text . 'on ' . date("d-m-Y h:i:s e") . 'with Transaction ID = ' . $refundtrx->transaction_id . ' using ' . strtoupper($refundtrx->transaction_type) . ' and authorization code ' . $refundtrx->authorization_code, 'woocommerce'));
                 $wc_order->update_status('wc-cancelled');
                 return true;
             } else {
                 $wc_order->add_order_note(__($refundtrx->response_reason_text . '--' . $refundtrx->error_message . ' on ' . date("d-m-Y h:i:s e") . ' using ' . strtoupper($refundtrx->transaction_type), 'woocommerce'));
                 return false;
             }
         } else {
             $wc_order->add_order_note(__($refundtrx->response_reason_text . '--' . $refundtrx->error_message . ' on ' . date("d-m-Y h:i:s e") . ' using ' . strtoupper($refundtrx->transaction_type), 'woocommerce'));
             return false;
         }
         return false;
     }
     return false;
 }
开发者ID:samiksha369,项目名称:majorcraft,代码行数:64,代码来源:authorize.net-woocommerce-addon.php

示例12: WooCommerceProcessTransaction

 public function WooCommerceProcessTransaction($order_id)
 {
     //affiliates manager code
     WPAM_Logger::log_debug('WooCommerce Integration - Order processed. Order ID: ' . $order_id);
     if (wpam_has_purchase_record($order_id)) {
         WPAM_Logger::log_debug('WooCommerce Integration - Affiliate commission for this transaction was awarded once. No need to process anything.');
         return;
     }
     WPAM_Logger::log_debug('WooCommerce Integration - Checking if affiliate commission needs to be awarded.');
     $order = new WC_Order($order_id);
     $recurring_payment_method = get_post_meta($order_id, '_recurring_payment_method', true);
     if (!empty($recurring_payment_method)) {
         WPAM_Logger::log_debug("WooCommerce Integration - This is a recurring payment order. Subscription payment method: " . $recurring_payment_method);
         WPAM_Logger::log_debug("The commission will be calculated via the recurring payemnt api call.");
         return;
     }
     $order_status = $order->status;
     WPAM_Logger::log_debug("WooCommerce Integration - Order status: " . $order_status);
     if (strtolower($order_status) != "completed" && strtolower($order_status) != "processing") {
         WPAM_Logger::log_debug("WooCommerce Integration - Order status for this transaction is not in a 'completed' or 'processing' state. Commission will not be awarded at this stage.");
         WPAM_Logger::log_debug("WooCommerce Integration - Commission for this transaciton will be awarded when you set the order status to completed or processing.");
         return;
     }
     $total = $order->order_total;
     $shipping = $order->get_total_shipping();
     $tax = $order->get_total_tax();
     WPAM_Logger::log_debug('WooCommerce Integration - Total amount: ' . $total . ', Total shipping: ' . $shipping . ', Total tax: ' . $tax);
     $purchaseAmount = $total - $shipping - $tax;
     $wpam_refkey = get_post_meta($order_id, '_wpam_refkey', true);
     $wpam_id = get_post_meta($order_id, '_wpam_id', true);
     if (!empty($wpam_id)) {
         $wpam_refkey = $wpam_id;
     }
     $wpam_refkey = apply_filters('wpam_woo_override_refkey', $wpam_refkey, $order);
     if (empty($wpam_refkey)) {
         WPAM_Logger::log_debug("WooCommerce Integration - could not get wpam_id/wpam_refkey from cookie. This is not an affiliate sale");
         return;
     }
     $requestTracker = new WPAM_Tracking_RequestTracker();
     WPAM_Logger::log_debug('WooCommerce Integration - awarding commission for order ID: ' . $order_id . '. Purchase amount: ' . $purchaseAmount);
     $requestTracker->handleCheckoutWithRefKey($order_id, $purchaseAmount, $wpam_refkey);
 }
开发者ID:hizamomar,项目名称:affiliates-manager-plugin,代码行数:42,代码来源:Plugin.php

示例13: array

    /**
     * Google Analytics eCommerce tracking
     *
     * @access public
     * @param mixed $order_id
     * @return void
     */
    function ecommerce_tracking_code($order_id)
    {
        global $woocommerce;
        if ($this->disable_tracking($this->ga_eeT) || current_user_can("manage_options") || get_post_meta($order_id, "_tracked", true) == 1) {
            return;
        }
        $tracking_id = $this->ga_id;
        if (!$tracking_id) {
            return;
        }
        // Doing eCommerce tracking so unhook standard tracking from the footer
        remove_action("wp_footer", array($this, "ee_settings"));
        // Get the order and output tracking code
        $order = new WC_Order($order_id);
        //Get Applied Coupon Codes
        $coupons_list = '';
        if ($order->get_used_coupons()) {
            $coupons_count = count($order->get_used_coupons());
            $i = 1;
            foreach ($order->get_used_coupons() as $coupon) {
                $coupons_list .= $coupon;
                if ($i < $coupons_count) {
                    $coupons_list .= ', ';
                }
                $i++;
            }
        }
        //get domain name if value is set
        if (!empty($this->ga_Dname)) {
            $set_domain_name = esc_js($this->ga_Dname);
        } else {
            $set_domain_name = "auto";
        }
        //add display features
        if ($this->ga_DF) {
            $ga_display_feature_code = 'ga("require", "displayfeatures");';
        } else {
            $ga_display_feature_code = "";
        }
        //add Pageview on order page if user checked Add Standard UA code
        if ($this->ga_ST) {
            $ga_pageview = 'ga("send", "pageview");';
        } else {
            $ga_pageview = "";
        }
        $code = '(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
			(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
			m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
			})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
                        
			ga("create", "' . esc_js($tracking_id) . '", "' . $set_domain_name . '");
                        ' . $ga_display_feature_code . '
			ga("require", "ec", "ec.js");
                        ' . $ga_pageview . '
                        ';
        // Order items
        if ($order->get_items()) {
            foreach ($order->get_items() as $item) {
                $_product = $order->get_product_from_item($item);
                if (isset($_product->variation_data)) {
                    $categories = esc_js(woocommerce_get_formatted_variation($_product->variation_data, true));
                } else {
                    $out = array();
                    $categories = get_the_terms($_product->id, "product_cat");
                    if ($categories) {
                        foreach ($categories as $category) {
                            $out[] = $category->name;
                        }
                    }
                    $categories = esc_js(join(",", $out));
                }
                //orderpage Prod json
                $orderpage_prod_Array[get_permalink($_product->id)] = array("tvc_id" => esc_html($_product->id), "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->id), "tvc_n" => esc_js($item["name"]), "tvc_p" => esc_js($order->get_item_total($item)), "tvc_c" => $categories, "tvc_q" => esc_js($item["qty"]));
            }
            //make json for prod meta data on order page
            $this->wc_version_compare("tvc_oc=" . json_encode($orderpage_prod_Array) . ";");
        }
        //get shipping cost based on version >2.1 get_total_shipping() < get_shipping
        if (version_compare($woocommerce->version, "2.1", ">=")) {
            $tvc_sc = $order->get_total_shipping();
        } else {
            $tvc_sc = $order->get_shipping();
        }
        //orderpage transcation data json
        $orderpage_trans_Array = array("id" => esc_js($order->get_order_number()), "affiliation" => esc_js(get_bloginfo('name')), "revenue" => esc_js($order->get_total()), "tax" => esc_js($order->get_total_tax()), "shipping" => esc_js($tvc_sc), "coupon" => $coupons_list);
        //make json for trans data on order page
        $this->wc_version_compare("tvc_td=" . json_encode($orderpage_trans_Array) . ";");
        $code .= '
                //set local currencies
            ga("set", "&cu", tvc_lc);  
            for(var t_item in tvc_oc){
                ga("ec:addProduct", { 
                    "id": tvc_oc[t_item].tvc_i,
//.........这里部分代码省略.........
开发者ID:developmentDM2,项目名称:The-Haute-Mess,代码行数:101,代码来源:class-wc-enhanced-ecommerce-google-analytics-integration.php

示例14: process_payment

 /**
  * Process the payment and return the result
  *
  * @access public
  * @param int $order_id
  * @return array
  */
 public function process_payment($order_id)
 {
     $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);
         if (get_option('woocommerce_prices_include_tax') == 'yes') {
             $mj_order->add_item($item['name'], $wc_order->get_item_subtotal($item, true, false), $item['qty'], $product->get_sku());
         } else {
             $mj_order->add_item($item['name'], $wc_order->get_item_subtotal($item, false, true), $item['qty'], $product->get_sku());
         }
     }
     // Handle fees
     $items = $wc_order->get_fees();
     foreach ($items as $item) {
         $mj_order->add_item($item['name'], number_format($item['line_total'], 2, '.', ','), 1, '');
     }
     // 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_total();
     $mj_order->discount = $wc_order->get_total_discount();
     if (get_option('woocommerce_prices_include_tax') == 'yes') {
         $mj_order->shipping = round($wc_order->get_total_shipping() + $wc_order->get_shipping_tax(), 2);
         $mj_order->show_tax = false;
     } else {
         $mj_order->shipping = round($wc_order->get_total_shipping(), 2);
         $mj_order->tax = $wc_order->get_total_tax();
     }
     // 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_Gateway_Mijireh', 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) {
         wc_add_notice(__('Mijireh error:', 'woocommerce') . $e->getMessage(), 'error');
     }
 }
开发者ID:Joaquinsemp,项目名称:patriestausado,代码行数:84,代码来源:class-wc-gateway-mijireh.php

示例15: get_total_shipping

 /**
  * Returns the total shipping cost for the given order
  *
  * @since 2.0
  * @param WC_Order $order
  * @return float the shipping total
  */
 public static function get_total_shipping($order)
 {
     if (self::is_wc_version_gte_2_1()) {
         return $order->get_total_shipping();
     } else {
         return $order->get_shipping();
     }
 }
开发者ID:nomadicmarc,项目名称:goodbay,代码行数:15,代码来源:class-sv-wc-plugin-compatibility.php


注:本文中的WC_Order::get_total_shipping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。