本文整理汇总了PHP中WC_Order::get_subtotal方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::get_subtotal方法的具体用法?PHP WC_Order::get_subtotal怎么用?PHP WC_Order::get_subtotal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Order
的用法示例。
在下文中一共展示了WC_Order::get_subtotal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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_subtotal = $order->get_subtotal();
$other_cost = $order_total - $order_subtotal;
$order_status = $order->post_status;
$net_amount = $order_subtotal * $percentage / 100 + $other_cost;
$net_amount = apply_filters('dokan_order_net_amount', $net_amount, $order, $seller_id, $percentage);
$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'));
}
示例4: 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
示例5: get_subtotal_incl_tax
/**
* Get the subtotal without discount and shipping, but including tax.
* @return mixed|void
*/
public function get_subtotal_incl_tax()
{
return $this->order->get_subtotal() + $this->order->get_total_tax();
}
示例6: addRoyaltyPoint
function addRoyaltyPoint($order_id)
{
if (!get_current_user_id()) {
return false;
}
$order = new WC_Order($order_id);
$subtotal = $order->get_subtotal();
$pointsAdjustment = $subtotal - $order->cart_discount;
$cardNo = get_cimyFieldValue(get_current_user_id(), 'CARD_NO');
$userInfo = array("CARD_NO" => $cardNo, "PLUS_POINT" => number_format($pointsAdjustment, 2));
$royaltyCardAPI = new royaltyCardAPI();
$rtnIncrementPoints = $royaltyCardAPI->incrementPoints($userInfo);
if ($rtnIncrementPoints == 'SUCCESS') {
//echo 'aaaa';
} else {
return new WP_Error(444, $rtnIncrementPoints);
}
}
示例7: sendCustomerInvoice
function sendCustomerInvoice($order_id)
{
PlexLog::addLog(' Info =>@sendCustomerInvoice order_id=' . $order_id);
$wooCommerceOrderObject = new WC_Order($order_id);
$user_id = $wooCommerceOrderObject->get_user_id();
$customerMailId = $wooCommerceOrderObject->billing_email;
$invoice_mail_content = '';
$invoice_mail_content .= '
<table border="0" cellpadding="0" cellspacing="0" width="600" id="template_container">
<tbody>
<tr>
<td align="center" valign="top">
<font face="Arial" style="font-weight:bold;background-color:#8fd1c8;color:#202020;"></font>
<table border="0" cellpadding="0" cellspacing="0" width="600" id="template_header" bgcolor="#8fd1c8">
<tbody>
<tr >
<td width="20" height="20" bgcolor="#8fd1c8"> </td>
<td bgcolor="#8fd1c8"> </td>
<td width="20" bgcolor="#8fd1c8"> </td>
</tr>
<tr >
<td width="20" bgcolor="#8fd1c8"> </td>
<td bgcolor="#8fd1c8" style="font-weight:bold;font-size:24px;color:#ffffff;" ><h2 style="margin:0;">Welcome to ' . get_option('blogname') . '! <br>Thank you for your order. We\'ll be in touch shortly with additional order and shipping information.</h2></td>
<td width="20" bgcolor="#8fd1c8"> </td>
</tr>
<tr >
<td width="20" height="20" bgcolor="#8fd1c8"> </td>
<td bgcolor="#8fd1c8"> </td>
<td width="20" bgcolor="#8fd1c8"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="600" id="template_body">
<tbody>
<tr>
<td valign="top">
<font style="background-color:#f9f9f9">
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tbody>
<tr>
<td valign="top">
<div>
<font face="Arial" align="left" style="font-size:18px;color:#8a8a8a">
<p>Your order #' . get_post_meta($order_id, "plexOrderId", true) . ' has been received and is now being processed. Your order details are shown below for your reference:</p>
<table cellspacing="0" cellpadding="6" border="1" style="width:100%;">
<thead>
<tr>
<th scope="col">
<font align="left">Product</font>
</th>
<th scope="col">
<font align="left">Quantity</font>
</th>
<th scope="col">
<font align="left">Price</font>
</th>
</tr>
</thead>
<tbody>';
$allItems = $wooCommerceOrderObject->get_items();
foreach ($allItems as $key => $value) {
$invoice_mail_content .= '
<tr>
<td>
<font align="left">' . $value["name"] . '<br><small></small></font>
</td>
<td>
<font align="left">' . $value["qty"] . '</font>
</td>
<td>
<font align="left">
<span class="amount">$' . $value["line_subtotal"] . '</span>
</font>
</td>
</tr>';
}
$invoice_mail_content .= '
</tbody>
<tfoot style="text-align: left;">
<tr>
<th scope="row" colspan="2">
<font align="left">Cart Subtotal:</font>
</th>
<td>
<font align="left">
<span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_subtotal()) . '</span>
</font>
</td>
</tr>';
if ($wooCommerceOrderObject->get_total_discount() > 0.0) {
$invoice_mail_content .= '<tr>
<th scope="row" colspan="2">
<font align="left">Discount:</font>
</th>
<td>
<font align="left">
//.........这里部分代码省略.........