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


PHP WC_Order::get_total_tax方法代码示例

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


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

示例1:

 function meta_box()
 {
     global $woocommerce, $post;
     $order = new WC_Order($post->ID);
     $order_discount = $order->get_total_discount();
     $order_tax = $order->get_total_tax();
     $order_subtotal = $order->get_subtotal_to_display();
     $order_total = $order->get_formatted_order_total();
     get_payment_gateway_fields('paypal');
     woocommerce_wp_select(array('id' => 'payment_type', 'label' => '', 'value' => 'default', 'options' => ins_get_payment_methods(), 'class' => 'chosen-select'));
     woocommerce_wp_select(array('id' => 'add_coupon', 'label' => '', 'value' => 'default', 'options' => ins_get_coupons(), 'class' => 'chosen-select'));
     woocommerce_wp_text_input(array('id' => 'sub_total', 'label' => __('Order Subtotal', 'instore'), 'placeholder' => 0.0, 'value' => $order_subtotal));
     woocommerce_wp_text_input(array('id' => 'order_tax', 'label' => __('Order Tax', 'instore'), 'placeholder' => 0.0, 'value' => $order_tax));
     woocommerce_wp_text_input(array('id' => 'applied_discount', 'label' => __('Applied Discount', 'instore'), 'placeholder' => 0.0, 'value' => $order_discount));
 }
开发者ID:jusmark123,项目名称:instore-Dev,代码行数:15,代码来源:class-instore-admin-shop-metabox.php

示例2: array


//.........这里部分代码省略.........
     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');
     }
     // Tax
     if ($order->get_total_tax() > 0) {
         $items[] = array('id' => 'taxfee', 'price' => $order->get_total_tax(), 'quantity' => 1, 'name' => 'Tax');
     }
     // Discount
     if ($cart->get_cart_discount_total() > 0) {
         $items[] = array('id' => 'totaldiscount', 'price' => $cart->get_cart_discount_total() * -1, 'quantity' => 1, 'name' => 'Total Discount');
     }
     // Fees
     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++;
         }
     }
     $total_amount = 0;
     // error_log('print r items[]' . print_r($items,true)); //debugan
     foreach ($items as $item) {
         $total_amount += $item['price'] * $item['quantity'];
         // error_log('|||| Per item[]' . print_r($item,true)); //debugan
     }
     error_log('order get total = ' . $order->get_total());
     error_log('total amount = ' . $total_amount);
     $params['transaction_details']['gross_amount'] = $total_amount;
     // sift through the entire item to ensure that currency conversion is applied
     if (get_woocommerce_currency() != 'IDR') {
         foreach ($items as &$item) {
             $item['price'] = $item['price'] * $this->to_idr_rate;
         }
         unset($item);
         $params['transaction_details']['gross_amount'] *= $this->to_idr_rate;
     }
     $params['item_details'] = $items;
     $woocommerce->cart->empty_cart();
     return Veritrans_VtWeb::getRedirectionUrl($params);
 }
开发者ID:rizdaprasetya,项目名称:veritrans-woocommerce,代码行数:101,代码来源:class.veritrans-gateway.php

示例3: get_line_items

 /**
  * Get line items to send to paypal
  *
  * @param  WC_Order $order
  * @return array on success, or false when it is not possible to send line items
  */
 private function get_line_items($order)
 {
     // Do not send lines for tax inclusive prices
     if ('yes' === get_option('woocommerce_calc_taxes') && 'yes' === get_option('woocommerce_prices_include_tax')) {
         return false;
     }
     // Do not send lines when order discount is present, or too many line items in the order.
     if ($order->get_order_discount() > 0 || sizeof($order->get_items()) + sizeof($order->get_fees()) >= 9) {
         return false;
     }
     $item_loop = 0;
     $args = array();
     $args['tax_cart'] = $order->get_total_tax();
     // Products
     if (sizeof($order->get_items()) > 0) {
         foreach ($order->get_items() as $item) {
             if (!$item['qty']) {
                 continue;
             }
             $item_loop++;
             $product = $order->get_product_from_item($item);
             $item_name = $item['name'];
             $item_meta = new WC_Order_Item_Meta($item['item_meta']);
             if ($meta = $item_meta->display(true, true)) {
                 $item_name .= ' ( ' . $meta . ' )';
             }
             $args['item_name_' . $item_loop] = $this->paypal_item_name($item_name);
             $args['quantity_' . $item_loop] = $item['qty'];
             $args['amount_' . $item_loop] = $order->get_item_subtotal($item, false);
             if ($args['amount_' . $item_loop] < 0) {
                 return false;
                 // Abort - negative line
             }
             if ($product->get_sku()) {
                 $args['item_number_' . $item_loop] = $product->get_sku();
             }
         }
     }
     // Discount
     if ($order->get_cart_discount() > 0) {
         $args['discount_amount_cart'] = round($order->get_cart_discount(), 2);
     }
     // Fees
     if (sizeof($order->get_fees()) > 0) {
         foreach ($order->get_fees() as $item) {
             $item_loop++;
             $args['item_name_' . $item_loop] = $this->paypal_item_name($item['name']);
             $args['quantity_' . $item_loop] = 1;
             $args['amount_' . $item_loop] = $item['line_total'];
             if ($args['amount_' . $item_loop] < 0) {
                 return false;
                 // Abort - negative line
             }
         }
     }
     // Shipping Cost item - paypal only allows shipping per item, we want to send shipping for the order
     if ($order->get_total_shipping() > 0) {
         $item_loop++;
         $args['item_name_' . $item_loop] = $this->paypal_item_name(sprintf(__('Shipping via %s', 'woocommerce'), $order->get_shipping_method()));
         $args['quantity_' . $item_loop] = '1';
         $args['amount_' . $item_loop] = number_format($order->get_total_shipping(), 2, '.', '');
     }
     return $args;
 }
开发者ID:GaryJones,项目名称:goombiel,代码行数:70,代码来源:class-wc-gateway-paypal.php

示例4: dokan_sync_insert_order

/**
 * Insert a order in sync table once a order is created
 *
 * @global object $wpdb
 * @param int $order_id
 */
function dokan_sync_insert_order($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);
    $order_total = $order->get_total();
    $order_shipping = $order->get_total_shipping();
    $order_tax = $order->get_total_tax();
    $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_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:CPHollister,项目名称:shyftmodels,代码行数:22,代码来源:order-functions.php

示例5: transaction_request

 /**
  * Perform a credit card transaction request
  *
  * @param Elavon_VM_API $elavon_client elavon api client
  * @param WC_Order $order the order
  *
  * @return SimpleXMLElement response, or false on error
  */
 private function transaction_request($elavon_client, $order)
 {
     $request = new stdClass();
     $request->ssl_test_mode = $this->is_test_mode() ? "true" : "false";
     $request->ssl_transaction_type = $this->auth_settle() ? "ccsale" : "ccauthonly";
     $request->ssl_invoice_number = ltrim($order->get_order_number(), _x('#', 'hash before order number', WC_Elavon_VM::TEXT_DOMAIN));
     $request->ssl_card_number = $this->get_post('elavon_vm_accountNumber');
     $request->ssl_exp_date = $this->get_post('elavon_vm_expirationMonth') . substr($this->get_post('elavon_vm_expirationYear'), -2);
     $request->ssl_amount = number_format($order->get_total(), 2, '.', '');
     $request->ssl_salestax = number_format($order->get_total_tax(), 2);
     // Note:  this is a fix suggested by Elavon that should work "90%" of the time.  We'll go with it for now, until someone really needs a POID field collected on the frontend
     $request->ssl_customer_code = substr($this->get_post('elavon_vm_accountNumber'), -4);
     $request->ssl_cvv2cvc2_indicator = $this->cvv_required() ? "1" : "0";
     if ($this->cvv_required()) {
         $request->ssl_cvv2cvc2 = $this->get_post('elavon_vm_cvNumber');
     }
     $request->ssl_first_name = $order->billing_first_name;
     $request->ssl_last_name = $order->billing_last_name;
     $request->ssl_company = $order->billing_company;
     $request->ssl_avs_address = $order->billing_address_1;
     $request->ssl_address2 = $order->billing_address_2;
     $request->ssl_city = $order->billing_city;
     $request->ssl_state = $order->billing_state;
     $request->ssl_avs_zip = $order->billing_postcode;
     $request->ssl_country = $order->billing_country;
     // country code
     $request->ssl_email = $order->billing_email;
     $request->ssl_phone = preg_replace('/[^0-9]/', '', $order->billing_phone);
     $request->ssl_cardholder_ip = $_SERVER['REMOTE_ADDR'];
     return $elavon_client->transaction_request($request);
 }
开发者ID:adrianjonmiller,项目名称:vadsupplies,代码行数:39,代码来源:class-wc-gateway-elavon-vm.php

示例6: orderpost

function orderpost($orderId)
{
    global $wpdb;
    $testMode = get_option('linksync_test');
    $LAIDKey = get_option('linksync_laid');
    $apicall = new linksync_class($LAIDKey, $testMode);
    //Checking for already sent Order
    $sentOrderIds = get_option('linksync_sent_order_id');
    if (isset($sentOrderIds)) {
        if (!empty($sentOrderIds)) {
            $order_id_array = unserialize($sentOrderIds);
        } else {
            $order_id_array = array();
        }
        if (!in_array($orderId, $order_id_array)) {
            $order = new WC_Order($orderId);
            if ($order->post_status == get_option('order_status_wc_to_vend')) {
                update_option('linksync_sent_order_id', serialize(array_merge($order_id_array, array($orderId))));
                $order_no = $order->get_order_number();
                if (strpos($order_no, '#') !== false) {
                    $order_no = str_replace('#', '', $order_no);
                }
                $get_total = $order->get_total();
                $get_user = $order->get_user();
                $comments = $order->post->post_excerpt;
                $primary_email_address = $get_user->data->user_email;
                $currency = $order->get_order_currency();
                $shipping_method = $order->get_shipping_method();
                $order_total = $order->get_order_item_totals();
                $transaction_id = $order->get_transaction_id();
                $taxes_included = false;
                $total_discount = $order->get_total_discount();
                $total_quantity = 0;
                $registerDb = get_option('wc_to_vend_register');
                $vend_uid = get_option('wc_to_vend_user');
                $total_tax = $order->get_total_tax();
                // Geting Payment object details
                if (isset($order_total['payment_method']['value']) && !empty($order_total['payment_method']['value'])) {
                    $wc_payment = get_option('wc_to_vend_payment');
                    if (isset($wc_payment) && !empty($wc_payment)) {
                        $total_payments = explode(",", $wc_payment);
                        foreach ($total_payments as $mapped_payment) {
                            $exploded_mapped_payment = explode("|", $mapped_payment);
                            if (isset($exploded_mapped_payment[1]) && !empty($exploded_mapped_payment[1]) && isset($exploded_mapped_payment[0]) && !empty($exploded_mapped_payment[0])) {
                                if ($exploded_mapped_payment[1] == $order_total['payment_method']['value']) {
                                    $vend_payment_data = explode("%%", $exploded_mapped_payment[0]);
                                    if (isset($vend_payment_data[0])) {
                                        $payment_method = $vend_payment_data[0];
                                    }
                                    if (isset($vend_payment_data[1])) {
                                        $payment_method_id = $vend_payment_data[1];
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    $payment = array("retailer_payment_type_id" => isset($payment_method_id) ? $payment_method_id : null, "amount" => isset($get_total) ? $get_total : 0, "method" => isset($payment_method) ? $payment_method : null, "transactionNumber" => isset($transaction_id) ? $transaction_id : null);
                }
                $export_user_details = get_option('wc_to_vend_export');
                if (isset($export_user_details) && !empty($export_user_details)) {
                    if ($export_user_details == 'customer') {
                        //woocommerce filter
                        $billingAddress_filter = apply_filters('woocommerce_order_formatted_billing_address', array('firstName' => $order->billing_first_name, 'lastName' => $order->billing_last_name, 'phone' => $order->billing_phone, 'street1' => $order->billing_address_1, 'street2' => $order->billing_address_2, 'city' => $order->billing_city, 'state' => $order->billing_state, 'postalCode' => $order->billing_postcode, 'country' => $order->billing_country, 'company' => $order->billing_company, 'email_address' => $order->billing_email), $order);
                        $billingAddress = array('firstName' => $billingAddress_filter['firstName'], 'lastName' => $billingAddress_filter['lastName'], 'phone' => $billingAddress_filter['phone'], 'street1' => $billingAddress_filter['street1'], 'street2' => $billingAddress_filter['street2'], 'city' => $billingAddress_filter['city'], 'state' => $billingAddress_filter['state'], 'postalCode' => $billingAddress_filter['postalCode'], 'country' => $billingAddress_filter['country'], 'company' => $billingAddress_filter['company'], 'email_address' => $billingAddress_filter['email_address']);
                        $deliveryAddress_filter = apply_filters('woocommerce_order_formatted_shipping_address', array('firstName' => $order->shipping_first_name, 'lastName' => $order->shipping_last_name, 'phone' => $order->shipping_phone, 'street1' => $order->shipping_address_1, 'street2' => $order->shipping_address_2, 'city' => $order->shipping_city, 'state' => $order->shipping_state, 'postalCode' => $order->shipping_postcode, 'country' => $order->shipping_country, 'company' => $order->shipping_company), $order);
                        $deliveryAddress = array('firstName' => $deliveryAddress_filter['firstName'], 'lastName' => $deliveryAddress_filter['lastName'], 'phone' => $deliveryAddress_filter['phone'], 'street1' => $deliveryAddress_filter['street1'], 'street2' => $deliveryAddress_filter['street2'], 'city' => $deliveryAddress_filter['city'], 'state' => $deliveryAddress_filter['state'], 'postalCode' => $deliveryAddress_filter['postalCode'], 'country' => $deliveryAddress_filter['country'], 'company' => $deliveryAddress_filter['company']);
                        $primary_email = isset($primary_email_address) ? $primary_email_address : $billingAddress['email_address'];
                        unset($billingAddress['email_address']);
                    }
                }
                $vend_user_detail = get_option('wc_to_vend_user');
                if (isset($vend_user_detail) && !empty($vend_user_detail)) {
                    $user = explode('|', $vend_user_detail);
                    $vend_uid = isset($user[0]) ? $user[0] : null;
                    $vend_username = isset($user[1]) ? $user[1] : null;
                }
                //Ordered product(s)
                $items = $order->get_items();
                $taxes = $order->get_taxes();
                foreach ($items as $item) {
                    foreach ($taxes as $tax_label) {
                        $sql = mysql_query("SELECT  tax_rate_id FROM  `" . $wpdb->prefix . "woocommerce_tax_rates` WHERE  tax_rate_name='" . $tax_label['label'] . "' AND tax_rate_class='" . $item['item_meta']['_tax_class'][0] . "'");
                        if (mysql_num_rows($sql) != 0) {
                            $tax_classes = linksync_tax_classes($tax_label['label'], $item['item_meta']['_tax_class'][0]);
                            if ($tax_classes['result'] == 'success') {
                                $vend_taxes = explode('/', $tax_classes['tax_classes']);
                            }
                        }
                    }
                    $taxId = isset($vend_taxes[0]) ? $vend_taxes[0] : null;
                    $taxName = isset($vend_taxes[1]) ? $vend_taxes[1] : null;
                    $taxRate = isset($vend_taxes[2]) ? $vend_taxes[2] : null;
                    if (isset($item['variation_id']) && !empty($item['variation_id'])) {
                        $product_id = $item['variation_id'];
                    } else {
                        $product_id = $item['product_id'];
                    }
                    $pro_object = new WC_Product($product_id);
                    $itemtotal = (double) $item['item_meta']['_line_subtotal'][0];
//.........这里部分代码省略.........
开发者ID:amanpreet8333,项目名称:linksync,代码行数:101,代码来源:linksync_add_action_order.php

示例7: 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

示例8: 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

示例9: 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

示例10: ConfirmPayment


//.........这里部分代码省略.........
              */
             if (get_option('woocommerce_prices_include_tax') == 'yes') {
                 $product_price = $order->get_item_subtotal($values, true, false);
             } else {
                 $product_price = $order->get_item_subtotal($values, false, true);
             }
             $Item = array('name' => $values['name'], 'desc' => '', 'amt' => $product_price, 'number' => $sku, 'qty' => $qty, 'taxamt' => '', 'itemurl' => '', 'itemcategory' => '', 'itemweightvalue' => '', 'itemweightunit' => '', 'itemheightvalue' => '', 'itemheightunit' => '', 'itemwidthvalue' => '', 'itemwidthunit' => '', 'itemlengthvalue' => '', 'itemlengthunit' => '', 'ebayitemnumber' => '', 'ebayitemauctiontxnid' => '', 'ebayitemorderid' => '', 'ebayitemcartid' => '');
             array_push($PaymentOrderItems, $Item);
             $ITEMAMT += $product_price * $values['qty'];
         }
         /**
          * Add custom Woo cart fees as line items
          */
         foreach (WC()->cart->get_fees() as $fee) {
             $Item = array('name' => $fee->name, 'desc' => '', 'amt' => number_format($fee->amount, 2, '.', ''), 'number' => $fee->id, 'qty' => 1, 'taxamt' => '', 'itemurl' => '', 'itemcategory' => '', 'itemweightvalue' => '', 'itemweightunit' => '', 'itemheightvalue' => '', 'itemheightunit' => '', 'itemwidthvalue' => '', 'itemwidthunit' => '', 'itemlengthvalue' => '', 'itemlengthunit' => '', 'ebayitemnumber' => '', 'ebayitemauctiontxnid' => '', 'ebayitemorderid' => '', 'ebayitemcartid' => '');
             /**
              * The gift wrap amount actually has its own parameter in
              * DECP, so we don't want to include it as one of the line
              * items.
              */
             if ($Item['number'] != 'gift-wrap') {
                 array_push($PaymentOrderItems, $Item);
                 $ITEMAMT += $fee->amount * $Item['qty'];
             }
             $ctr++;
         }
         /*
          * Get discounts
          */
         if ($order->get_cart_discount() > 0) {
             foreach (WC()->cart->get_coupons('cart') as $code => $coupon) {
                 $Item = array('name' => 'Cart Discount', 'number' => $code, 'qty' => '1', 'amt' => '-' . number_format(WC()->cart->coupon_discount_amounts[$code], 2, '.', ''));
                 array_push($PaymentOrderItems, $Item);
             }
             $ITEMAMT -= $order->get_cart_discount();
         }
         if ($order->get_order_discount() > 0) {
             foreach (WC()->cart->get_coupons('order') as $code => $coupon) {
                 $Item = array('name' => 'Order Discount', 'number' => $code, 'qty' => '1', 'amt' => '-' . number_format(WC()->cart->coupon_discount_amounts[$code], 2, '.', ''));
                 array_push($PaymentOrderItems, $Item);
             }
             $ITEMAMT -= $order->get_order_discount();
         }
         /*
          * Set shipping and tax values.
          */
         if (get_option('woocommerce_prices_include_tax') == 'yes') {
             $shipping = $order->get_total_shipping() + $order->get_shipping_tax();
             $tax = 0;
         } else {
             $shipping = $order->get_total_shipping();
             $tax = $order->get_total_tax();
         }
         /*
          * Now that we have all items and subtotals
          * we can fill in necessary values.
          */
         $Payment['itemamt'] = number_format($ITEMAMT, 2, '.', '');
         // Required if you specify itemized L_AMT fields. Sum of cost of all items in this order.
         /*
          * Set tax
          */
         if ($tax > 0) {
             $Payment['taxamt'] = number_format($tax, 2, '.', '');
             // Required if you specify itemized L_TAXAMT fields.  Sum of all tax items in this order.
         }
         /*
          * Set shipping
          */
         if ($shipping > 0) {
             $Payment['shippingamt'] = number_format($shipping, 2, '.', '');
             // Total shipping costs for this order.  If you specify SHIPPINGAMT you mut also specify a value for ITEMAMT.
         }
     }
     $Payment['order_items'] = $PaymentOrderItems;
     array_push($Payments, $Payment);
     $UserSelectedOptions = array('shippingcalculationmode' => '', 'insuranceoptionselected' => '', 'shippingoptionisdefault' => '', 'shippingoptionamount' => '', 'shippingoptionname' => '');
     $PayPalRequestData = array('DECPFields' => $DECPFields, 'Payments' => $Payments);
     // Pass data into class for processing with PayPal and load the response array into $PayPalResult
     $PayPalResult = $PayPal->DoExpressCheckoutPayment($PayPalRequestData);
     /*
      * Log API result
      */
     $this->add_log('Test Mode: ' . $this->testmode);
     $this->add_log('Endpoint: ' . $this->API_Endpoint);
     $PayPalRequest = isset($PayPalResult['RAWREQUEST']) ? $PayPalResult['RAWREQUEST'] : '';
     $PayPalResponse = isset($PayPalResult['RAWRESPONSE']) ? $PayPalResult['RAWRESPONSE'] : '';
     $this->add_log('Request: ' . print_r($PayPal->NVPToArray($PayPal->MaskAPIResult($PayPalRequest)), true));
     $this->add_log('Response: ' . print_r($PayPal->NVPToArray($PayPal->MaskAPIResult($PayPalResponse)), true));
     /*
      * Error handling
      */
     if ($PayPal->APICallSuccessful($PayPalResult['ACK'])) {
         $this->remove_session('TOKEN');
     }
     /*
      * Return the class library result array.
      */
     return $PayPalResult;
 }
开发者ID:sergioblanco86,项目名称:git-gitlab.com-kinivo-kinivo.com,代码行数:101,代码来源:wc-gateway-paypal-express-angelleye.php

示例11: foreach

 function get_payment_xml($order_id)
 {
     global $woocommerce;
     global $product;
     $order = new WC_Order($order_id);
     $Secuitems = '';
     foreach ($order->get_items() as $item) {
         $Options = array();
         foreach ($item as $Attribute => $Value) {
             if (!in_array($Attribute, $this->GetStandardProductFields())) {
                 $Options[$Attribute] = $Value;
             }
         }
         $product = new WC_Product($item['product_id']);
         $Secuitems .= '[' . $item['product_id'] . '|' . $product->get_sku() . '|' . $item['name'];
         if (!empty($Options)) {
             foreach ($Options as $Key => $Value) {
                 if ((string) $Key === 'pa_quantity') {
                     $Key = 'Quantity';
                 }
                 $Secuitems .= ', ' . $Key . ': ' . $Value;
             }
         }
         $Secuitems .= '|' . $this->currency_format($item['line_total'] / $item['qty']) . '|' . $item['qty'] . '|' . $this->currency_format($item['line_total']) . ']';
     }
     $TransactionSubTotal = $this->currency_format($order->get_subtotal());
     $TransactionAmount = $this->currency_format($order->get_total());
     $expirydate = str_replace(array('/', ' '), '', $_POST['UPG_api-card-expiry']);
     $cardnumber = str_replace(array(' ', '-'), '', $_POST['UPG_api-card-number']);
     $cardcv2 = str_replace(array(' ', '-'), '', $_POST['UPG_api-card-cvc']);
     $xmlContrsuct = '<?xml version ="1.0"?>';
     $xmlContrsuct .= '<request>';
     $xmlContrsuct .= '<type>transaction</type>';
     $xmlContrsuct .= '<authtype>authorise</authtype>';
     $xmlContrsuct .= '<authentication>';
     $xmlContrsuct .= '<shreference>' . $this->reference . '</shreference>';
     $xmlContrsuct .= '<checkcode>' . $this->checkcode . '</checkcode>';
     $xmlContrsuct .= '</authentication>';
     $xmlContrsuct .= '<transaction>';
     //Card details
     $xmlContrsuct .= '<cardnumber>' . $cardnumber . '</cardnumber>';
     $xmlContrsuct .= '<cv2>' . $cardcv2 . '</cv2>';
     $xmlContrsuct .= '<cardexpiremonth>' . substr($expirydate, 0, 2) . '</cardexpiremonth>';
     $xmlContrsuct .= '<cardexpireyear>' . substr($expirydate, -2) . '</cardexpireyear>';
     //Cardholder details
     $xmlContrsuct .= '<cardholdersname>' . $order->billing_first_name . ' ' . $order->billing_last_name . '</cardholdersname>';
     $xmlContrsuct .= '<cardholdersemail>' . $order->billing_email . '</cardholdersemail>';
     $xmlContrsuct .= '<cardholderaddr1>' . $order->billing_address_1 . '</cardholderaddr1>';
     $xmlContrsuct .= '<cardholderaddr2>' . $order->billing_address_2 . '</cardholderaddr2>';
     $xmlContrsuct .= '<cardholdercity>' . $order->billing_city . '</cardholdercity>';
     $xmlContrsuct .= '<cardholderstate>' . $order->billing_state . '</cardholderstate>';
     $xmlContrsuct .= '<cardholderpostcode>' . $order->billing_postcode . '</cardholderpostcode>';
     $xmlContrsuct .= '<cardholdercountry>' . $order->billing_country . '</cardholdercountry>';
     $xmlContrsuct .= '<cardholdertelephonenumber>' . $order->billing_phone . '</cardholdertelephonenumber>';
     // Order details
     $xmlContrsuct .= '<orderid>' . $order->id . '</orderid>';
     $xmlContrsuct .= '<subtotal>' . $TransactionSubTotal . '</subtotal>';
     $xmlContrsuct .= '<transactionamount>' . $TransactionAmount . '</transactionamount>';
     $xmlContrsuct .= '<transactioncurrency>' . get_woocommerce_currency() . '</transactioncurrency>';
     $xmlContrsuct .= '<transactiondiscount>' . $this->currency_format($order->get_total_discount()) . '</transactiondiscount>';
     $xmlContrsuct .= '<transactiontax>' . $this->currency_format($order->get_total_tax()) . '</transactiontax>';
     $xmlContrsuct .= '<shippingcharge>' . $this->currency_format($order->get_total_shipping()) . '</shippingcharge>';
     $xmlContrsuct .= '<secuitems><![CDATA[' . $Secuitems . ']]></secuitems>';
     $xmlContrsuct .= '</transaction>';
     $xmlContrsuct .= '</request>';
     return $xmlContrsuct;
 }
开发者ID:BeeHealthLimited,项目名称:WooCommerce-UPG-XML-Direct-Payment-Gateway,代码行数:67,代码来源:woocommerce-upg-api-gateway.php

示例12: 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

示例13: get_params_post

 /**
  * Construye un arreglo con todos los parametros que seran enviados al gateway de PayU Latam
  *
  * @access public
  * @return void
  */
 public function get_params_post($order_id)
 {
     global $woocommerce;
     $order = new WC_Order($order_id);
     $currency = get_woocommerce_currency();
     $amount = number_format($order->get_total(), 2, '.', '');
     $signature = md5($this->api_key . '~' . $this->merchant_id . '~' . $order->id . '~' . $amount . '~' . $currency);
     $description = "";
     $products = $order->get_items();
     foreach ($products as $product) {
         $description .= $product['name'] . ',';
     }
     $tax = number_format($order->get_total_tax(), 2, '.', '');
     $taxReturnBase = number_format($amount - $tax, 2, '.', '');
     if ($tax == 0) {
         $taxReturnBase = 0;
     }
     $test = 0;
     if ($this->test == 'yes') {
         $test = 1;
     }
     $parameters_args = array('merchantId' => $this->merchant_id, 'referenceCode' => $order->id, 'description' => trim($description, ','), 'amount' => $amount, 'tax' => $tax, 'taxReturnBase' => $taxReturnBase, 'signature' => $signature, 'accountId' => $this->account_id, 'currency' => $currency, 'buyerEmail' => $order->billing_email, 'test' => $test, 'confirmationUrl' => $this->confirmation_page, 'responseUrl' => $this->response_page, 'shippingAddress' => $order->shipping_address_1, 'shippingCountry' => $order->shipping_country, 'shippingCity' => $order->shipping_city, 'billingAddress' => $order->billing_address_1, 'billingCountry' => $order->billing_country, 'billingCity' => $order->billing_city, 'extra1' => 'WOOCOMMERCE');
     return $parameters_args;
 }
开发者ID:Jiersone,项目名称:mac,代码行数:30,代码来源:payu-latam.php

示例14: 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

示例15: woocommerce_ecommerce_tracking_piwik

/**
 * ecommerce tracking with piwik.
 *
 * @access public
 * @param int $order_id
 * @return void
 */
function woocommerce_ecommerce_tracking_piwik($order_id)
{
    global $woocommerce;
    // Don't track admin
    if (current_user_can('manage_options')) {
        return;
    }
    // Call the Piwik ecommerce function if WP-Piwik is configured to add tracking codes to the page
    $wp_piwik_global_settings = get_option('wp-piwik_global-settings');
    // Return if Piwik settings are not here, or if global is not set
    if (!isset($wp_piwik_global_settings['add_tracking_code']) || !$wp_piwik_global_settings['add_tracking_code']) {
        return;
    }
    if (!isset($GLOBALS['wp_piwik'])) {
        return;
    }
    // Get the order and get tracking code
    $order = new WC_Order($order_id);
    ob_start();
    ?>
	try {
		// Add order items
		<?php 
    if ($order->get_items()) {
        foreach ($order->get_items() as $item) {
            $_product = $order->get_product_from_item($item);
            ?>

			piwikTracker.addEcommerceItem(
				"<?php 
            echo esc_js($_product->get_sku());
            ?>
",			// (required) SKU: Product unique identifier
				"<?php 
            echo esc_js($item['name']);
            ?>
",					// (optional) Product name
				"<?php 
            if (isset($_product->variation_data)) {
                echo esc_js(woocommerce_get_formatted_variation($_product->variation_data, true));
            }
            ?>
",	// (optional) Product category. You can also specify an array of up to 5 categories eg. ["Books", "New releases", "Biography"]
				<?php 
            echo esc_js($order->get_item_total($item));
            ?>
,	// (recommended) Product price
				<?php 
            echo esc_js($item['qty']);
            ?>
 						// (optional, default to 1) Product quantity
			);

		<?php 
        }
    }
    ?>

		// Track order
		piwikTracker.trackEcommerceOrder(
			"<?php 
    echo esc_js($order->get_order_number());
    ?>
",	// (required) Unique Order ID
			<?php 
    echo esc_js($order->get_total());
    ?>
,			// (required) Order Revenue grand total (includes tax, shipping, and subtracted discount)
			false,													// (optional) Order sub total (excludes shipping)
			<?php 
    echo esc_js($order->get_total_tax());
    ?>
,		// (optional) Tax amount
			<?php 
    echo esc_js($order->get_shipping());
    ?>
,		// (optional) Shipping amount
			false 													// (optional) Discount offered (set to false for unspecified parameter)
		);
	} catch( err ) {}
	<?php 
    $code = ob_get_clean();
    $woocommerce->add_inline_js($code);
}
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:91,代码来源:woocommerce-functions.php


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