本文整理汇总了PHP中WC_Order::get_shipping_method方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::get_shipping_method方法的具体用法?PHP WC_Order::get_shipping_method怎么用?PHP WC_Order::get_shipping_method使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Order
的用法示例。
在下文中一共展示了WC_Order::get_shipping_method方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replace_placeholders
private function replace_placeholders($str)
{
$placeholders = apply_filters('bewpi_placeholders', array('[payment_method]' => $this->order->payment_method_title, '[shipping_method]' => $this->order->get_shipping_method()), $this->order->id);
foreach ($placeholders as $placeholder => $value) {
$str = str_replace($placeholder, $value, $str);
}
return $str;
}
示例2: 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;
}
示例3: round
$totalAmount += $item_price * (int) $item['qty'];
}
// End if qty
}
// End foreach
}
// End if sizeof get_items()
// We manually calculate the tax percentage here
if ($order->get_total_shipping() > 0) {
// Calculate tax percentage
$shipping_tax_percentage = round($order->get_shipping_tax() / $order->get_total_shipping(), 2) * 100;
} else {
$shipping_tax_percentage = 00;
}
$shipping_price = number_format(($order->get_total_shipping() + $order->get_shipping_tax()) * 100, 0, '', '');
$cart[] = array('ArticleNumber' => '999', 'ArticleName' => $order->get_shipping_method(), 'Description' => $order->get_shipping_method(), 'Quantity' => 100, 'Price' => intval($shipping_price), 'VAT' => intval($shipping_tax_percentage . '00'));
$totalAmount += $shipping_price;
//Create postData
$create['MerchantKey'] = $merchantid;
$create['Checksum'] = SHA1($totalAmount * 100 . $sharedSecret);
$create['Token'] = strtoupper($storedGet['token']);
foreach ($cart as $item) {
$create['Articles'][] = $item;
}
// Setup cURL
$ch = curl_init($updateCheckoutAPI);
curl_setopt_array($ch, array(CURLOPT_POST => TRUE, CURLOPT_RETURNTRANSFER => 1, CURLOPT_HTTPHEADER => array('Content-Type: application/json'), CURLOPT_POSTFIELDS => json_encode($create)));
// Send the request
$response = curl_exec($ch);
}
}
示例4: 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);
}
示例5: array
/**
* Test: get_shipping_method
*/
function test_get_shipping_method()
{
$object = new WC_Order();
$rate = new WC_Shipping_Rate('flat_rate_shipping', 'Flat rate shipping', '10', array(), 'flat_rate');
$item = new WC_Order_Item_Shipping();
$item->set_props(array('method_title' => $rate->label, 'method_id' => $rate->id, 'total' => wc_format_decimal($rate->cost), 'taxes' => $rate->taxes, 'meta_data' => $rate->get_meta_data()));
$object->add_item($item);
$object->save();
$this->assertEquals('Flat rate shipping', $object->get_shipping_method());
$rate = new WC_Shipping_Rate('flat_rate_shipping', 'Flat rate shipping 2', '10', array(), 'flat_rate');
$item = new WC_Order_Item_Shipping();
$item->set_props(array('method_title' => $rate->label, 'method_id' => $rate->id, 'total' => wc_format_decimal($rate->cost), 'taxes' => $rate->taxes, 'meta_data' => $rate->get_meta_data()));
$object->add_item($item);
$object->save();
$this->assertEquals('Flat rate shipping, Flat rate shipping 2', $object->get_shipping_method());
}
示例6: get_shipping_data
/**
* Get shipping data.
*
* @param WC_Order $order
*
* @return array
*/
protected function get_shipping_data($order)
{
$data = array('shipping_address_name' => $order->shipping_address_1, 'shipping_address_number' => $order->shipping_number, 'shipping_address_complement' => $order->shipping_address_2, 'shipping_address_district' => $order->shipping_neighborhood, 'shipping_address_city' => $order->shipping_city, 'shipping_address_state' => $order->shipping_state, 'shipping_zipcode' => $this->only_numbers($order->shipping_postcode));
if (0 < $order->get_total_shipping()) {
$data['shipping_type'] = '2';
// Flat rate.
$data['shipping_1_name'] = $order->get_shipping_method();
$data['shipping_1_price'] = $this->get_price($order->get_total_shipping());
} else {
$data['shipping_type'] = '3';
}
return $data;
}
示例7: 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;
}
示例8: 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];
//.........这里部分代码省略.........
示例9: array
/**
* Tracks a checkout
* @return none
*/
function track_checkout($order_id, $params)
{
$this->user["wc cart size"] = 0;
$this->user["wc cart value"] = 0;
if (!is_user_logged_in()) {
$this->user['name'] = $params["billing_first_name"] . " " . $params["billing_last_name"];
$this->user['email'] = $params["billing_email"];
$this->woopra->identify($this->user);
} else {
$this->woopra_detect();
}
global $woocommerce;
$cart = $woocommerce->cart;
$order = new WC_Order($order_id);
$new_params = array("cart subtotal" => $cart->subtotal, "cart value" => $order->get_total(), "cart size" => $order->get_item_count(), "payment method" => $params["payment_method"], "shipping method" => $order->get_shipping_method(), "order discount" => $order->get_total_discount(), "order number" => $order->get_order_number());
$this->woopra->track('wc checkout', $new_params, true);
}
示例10: custom_columns
/**
* Define our custom columns shown in admin.
* @param string $column
*/
public function custom_columns($column)
{
global $post, $woocommerce, $the_order;
if (empty($the_order) || $the_order->id != $post->ID) {
$the_order = new WC_Order($post->ID);
}
switch ($column) {
case 'order_status':
printf('<mark class="%s tips" data-tip="%s">%s</mark>', sanitize_title($the_order->status), esc_html__($the_order->status, 'woocommerce'), esc_html__($the_order->status, 'woocommerce'));
break;
case 'order_date':
if ('0000-00-00 00:00:00' == $post->post_date) {
$t_time = $h_time = __('Unpublished', 'woocommerce');
} else {
$t_time = get_the_time(__('Y/m/d g:i:s A', 'woocommerce'), $post);
$gmt_time = strtotime($post->post_date_gmt . ' UTC');
$time_diff = current_time('timestamp', 1) - $gmt_time;
$h_time = get_the_time(__('Y/m/d', 'woocommerce'), $post);
}
echo '<abbr title="' . esc_attr($t_time) . '">' . esc_html(apply_filters('post_date_column_time', $h_time, $post)) . '</abbr>';
break;
case 'customer_message':
if ($the_order->customer_message) {
echo '<span class="note-on tips" data-tip="' . esc_attr($the_order->customer_message) . '">' . __('Yes', 'woocommerce') . '</span>';
} else {
echo '<span class="na">–</span>';
}
break;
case 'billing_address':
if ($the_order->get_formatted_billing_address()) {
echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($the_order->get_billing_address()) . '&z=16') . '">' . esc_html(preg_replace('#<br\\s*/?>#i', ', ', $the_order->get_formatted_billing_address())) . '</a>';
} else {
echo '–';
}
if ($the_order->payment_method_title) {
echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($the_order->payment_method_title) . '</small>';
}
break;
case 'order_items':
printf('<a href="#" class="show_order_items">' . _n('%d item', '%d items', sizeof($the_order->get_items()), 'woocommerce') . '</a>', sizeof($the_order->get_items()));
if (sizeof($the_order->get_items()) > 0) {
echo '<table class="order_items" cellspacing="0">';
foreach ($the_order->get_items() as $item) {
$_product = apply_filters('woocommerce_order_item_product', $the_order->get_product_from_item($item), $item);
$item_meta = new WC_Order_Item_Meta($item['item_meta']);
$item_meta_html = $item_meta->display(true, true);
?>
<tr>
<td class="qty"><?php
echo absint($item['qty']);
?>
</td>
<td class="name">
<?php
if (wc_product_sku_enabled() && $_product && $_product->get_sku()) {
echo $_product->get_sku() . ' - ';
}
echo apply_filters('woocommerce_order_item_name', $item['name'], $item);
?>
<?php
if ($item_meta_html) {
?>
<a class="tips" href="#" data-tip="<?php
echo esc_attr($item_meta_html);
?>
">[?]</a>
<?php
}
?>
</td>
</tr>
<?php
}
echo '</table>';
} else {
echo '–';
}
break;
case 'shipping_address':
if ($the_order->get_formatted_shipping_address()) {
echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($the_order->get_shipping_address()) . '&z=16') . '">' . esc_html(preg_replace('#<br\\s*/?>#i', ', ', $the_order->get_formatted_shipping_address())) . '</a>';
} else {
echo '–';
}
if ($the_order->get_shipping_method()) {
echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($the_order->get_shipping_method()) . '</small>';
}
break;
case 'order_notes':
if ($post->comment_count) {
// check the status of the post
$post->post_status !== 'trash' ? $status = '' : ($status = 'post-trashed');
$latest_notes = get_comments(array('post_id' => $post->ID, 'number' => 1, 'status' => $status));
$latest_note = current($latest_notes);
if ($post->comment_count == 1) {
echo '<span class="note-on tips" data-tip="' . esc_attr($latest_note->comment_content) . '">' . __('Yes', 'woocommerce') . '</span>';
//.........这里部分代码省略.........
示例11: generate_invoice
public function generate_invoice($orderId)
{
global $wpdb, $woocommerce;
$order = new WC_Order($orderId);
$order_items = $order->get_items();
//Build Xml
$szamla = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><xmlszamla xmlns="http://www.szamlazz.hu/xmlszamla" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.szamlazz.hu/xmlszamla xmlszamla.xsd"></xmlszamla>');
//If custom details
if (isset($_POST['note']) && isset($_POST['deadline']) && isset($_POST['completed'])) {
$note = $_POST['note'];
$deadline = $_POST['deadline'];
$complated_date = $_POST['completed'];
} else {
$note = get_option('wc_szamlazz_note');
$deadline = get_option('wc_szamlazz_payment_deadline');
$complated_date = date('Y-m-d');
}
//Account & Invoice settings
$beallitasok = $szamla->addChild('beallitasok');
$beallitasok->addChild('felhasznalo', get_option('wc_szamlazz_username'));
$beallitasok->addChild('jelszo', get_option('wc_szamlazz_password'));
if (get_option('wc_szamlazz_invoice_type') != 'paper') {
$beallitasok->addChild('eszamla', 'true');
} else {
$beallitasok->addChild('eszamla', 'false');
}
$beallitasok->addChild('szamlaLetoltes', 'true');
//Invoice details
$fejlec = $szamla->addChild('fejlec');
$fejlec->addChild('keltDatum', date('Y-m-d'));
$fejlec->addChild('teljesitesDatum', $complated_date);
if ($deadline) {
$fejlec->addChild('fizetesiHataridoDatum', date('Y-m-d', strtotime('+' . $deadline . ' days')));
} else {
$fejlec->addChild('fizetesiHataridoDatum', date('Y-m-d'));
}
$fejlec->addChild('fizmod', $order->payment_method_title);
$fejlec->addChild('penznem', $order->get_order_currency());
$fejlec->addChild('szamlaNyelve', 'hu');
$fejlec->addChild('megjegyzes', $note);
if ($order->get_order_currency() != 'HUF') {
//if the base currency is not HUF, we should define currency rates
$fejlec->addChild('arfolyamBank', '');
$fejlec->addChild('arfolyam', 0);
}
$fejlec->addChild('rendelesSzam', $order->get_order_number());
$fejlec->addChild('elolegszamla', 'false');
$fejlec->addChild('vegszamla', 'false');
//Seller details
$elado = $szamla->addChild('elado');
//Customer details
$vevo = $szamla->addChild('vevo');
$vevo->addChild('nev', ($order->billing_company ? $order->billing_company . ' - ' : '') . $order->billing_first_name . ' ' . $order->billing_last_name);
$vevo->addChild('irsz', $order->billing_postcode);
$vevo->addChild('telepules', $order->billing_city);
$vevo->addChild('cim', $order->billing_address_1);
$vevo->addChild('email', $order->billing_email);
$vevo->addChild('adoszam', '');
$vevo->addChild('telefonszam', $order->billing_phone);
//Customer Shipping details if needed
if ($order->shipping_address) {
$vevo->addChild('postazasiNev', ($order->shipping_company ? $order->shipping_company . ' - ' : '') . $order->shipping_first_name . ' ' . $order->shipping_last_name);
$vevo->addChild('postazasiIrsz', $order->shipping_postcode);
$vevo->addChild('postazasiTelepules', $order->shipping_city);
$vevo->addChild('postazasiCim', $order->shipping_address_1);
}
//Order Items
$tetelek = $szamla->addChild('tetelek');
foreach ($order_items as $termek) {
$tetel = $tetelek->addChild('tetel');
$tetel->addChild('megnevezes', htmlspecialchars($termek["name"]));
$tetel->addChild('mennyiseg', $termek["qty"]);
$tetel->addChild('mennyisegiEgyseg', '');
$tetel->addChild('nettoEgysegar', round($termek["line_total"], 2) / $termek["qty"]);
$tetel->addChild('afakulcs', round($termek["line_tax"] / $termek["line_total"] * 100));
$tetel->addChild('nettoErtek', round($termek["line_total"], 2));
$tetel->addChild('afaErtek', round($termek["line_tax"], 2));
$tetel->addChild('bruttoErtek', round($termek["line_total"], 2) + round($termek["line_tax"], 2));
$tetel->addChild('megjegyzes', '');
}
//Shipping
if ($order->get_shipping_methods()) {
$tetel = $tetelek->addChild('tetel');
$tetel->addChild('megnevezes', htmlspecialchars($order->get_shipping_method()));
$tetel->addChild('mennyiseg', '1');
$tetel->addChild('mennyisegiEgyseg', '');
$tetel->addChild('nettoEgysegar', round($order->order_shipping, 2));
if ($order->order_shipping == 0) {
$tetel->addChild('afakulcs', '0');
} else {
$tetel->addChild('afakulcs', round($order->order_shipping_tax / $order->order_shipping * 100));
}
$tetel->addChild('nettoErtek', round($order->order_shipping, 2));
$tetel->addChild('afaErtek', round($order->order_shipping_tax, 2));
$tetel->addChild('bruttoErtek', round($order->order_shipping, 2) + round($order->order_shipping_tax, 2));
$tetel->addChild('megjegyzes', '');
}
//Extra Fees
$fees = $order->get_fees();
if (!empty($fees)) {
//.........这里部分代码省略.........
示例12: sendDataToEPOS
function sendDataToEPOS($order_id)
{
if (!session_id()) {
session_start();
}
$transaction_id = $_SESSION["TransactionID"];
$collection_time = $_SESSION["CollectionTime"];
$order = new WC_Order($order_id);
$itemList = array();
foreach ($order->get_items() as $key => $value) {
$epos_product_id = get_field('epos_product_id', $value["item_meta"]["_product_id"][0]);
$quantity = $value["item_meta"]["_qty"][0];
array_push($itemList, array("ID" => "{$epos_product_id}", "Quantity" => "{$quantity}"));
}
$discountAmount = $order->cart_discount;
$cartTotal = $order->get_total();
//shipping address
$customer_name = $order->shipping_first_name;
$customer_name .= ' ' . $order->shipping_last_name;
$shipping_address = $order->shipping_address_1;
$shipping_address .= ' ' . $order->shipping_address_2;
$shipping_address .= ' ' . $order->shipping_city;
$shipping_address .= ' ' . $order->shipping_state;
$shipping_postcode = $order->shipping_postcode;
$email = $order->billing_email;
$phone = $order->billing_phone;
$comment = $order->order_comments;
$shipping_fee = $order->get_total_shipping();
$today = date("d/m/Y");
$chosen_methods = $order->get_shipping_method();
$chosen_methods == 'Local Pickup' ? $chosen_shipping_id = 0 : ($chosen_shipping_id = 1);
//0=pick / 1=deli
//wc_add_notice( $amount2 ,'error' );
$jsonValue = array("APIKey" => royaltyCardAPI::APIKEY, "SiteID" => royaltyCardAPI::SITEID, "UserID" => "ab9d1dd6-52ea-4acf-bb29-06f2da959f33", "OrderItems" => $itemList, "OrderType" => $chosen_shipping_id, "RequiredDate" => $today, "RequiredTime" => $collection_time, "Name" => $customer_name, "DeliveryAddress" => $shipping_address, "DeliveryPostcode" => $shipping_postcode, "TelNo" => $phone, "Email" => $email, "DeliveryInstructions" => $comment, "DeliveryCost" => $shipping_fee, "PromoCode" => "sample", "PromoCodeDiscount" => $discountAmount, "Payment" => array("PaymentType" => "4", "TransactionID" => $transaction_id), "OrderTotal" => $cartTotal - $shipping_fee + $discountAmount);
$arg = array('method' => 'POST', 'timeout' => 120, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array('Content-Type' => 'application/json'), 'body' => json_encode($jsonValue, JSON_UNESCAPED_SLASHES));
$response = wp_remote_post(royaltyCardAPI::validateOrder, $arg);
if (is_wp_error($response)) {
//return $response->get_error_message();
wc_add_notice($response->get_error_message(), 'error');
}
$json_header = 'application/json; charset=utf-8';
if (!isset($response['headers']['content-type']) || $response['headers']['content-type'] != $json_header) {
return 'Error - Header is not json format, please contact us.';
}
$obj = json_decode($response['body']);
if (!is_a($obj, 'stdClass')) {
return 'Error - Data may not be correct format.';
}
if ($obj->Result == 4) {
//wc_add_notice( $obj->ResultString ,'error' );
echo $obj->ResultString;
session_destroy();
} else {
echo $obj->ResultString;
session_destroy();
}
}
示例13: array
$quantity = $value["item_meta"]["_qty"][0];
array_push($itemList, array("ID" => "{$epos_product_id}", "Quantity" => "{$quantity}"));
}
$cartTotal = $order->get_total();
//shipping address
$customer_name = $order->shipping_first_name;
$customer_name .= ' ' . $order->shipping_last_name;
$shipping_address = $order->shipping_address_1;
$shipping_address .= ' ' . $order->shipping_address_2;
$shipping_address .= ' ' . $order->shipping_city;
$shipping_address .= ' ' . $order->shipping_state;
$shipping_postcode = $order->shipping_postcode;
$email = $order->billing_email;
$phone = $order->billing_phone;
$comment = $order->order_comments;
$shipping_fee = $order->get_total_shipping();
$today = date("d/m/Y");
$chosen_methods = $order->get_shipping_method();
$chosen_methods == 'Local Pickup' ? $chosen_shipping_id = 0 : ($chosen_shipping_id = 1);
//0=pick / 1=deli
//wc_add_notice( $amount2 ,'error' );
$jsonValue = array("APIKey" => royaltyCardAPI::APIKEY, "SiteID" => royaltyCardAPI::SITEID, "UserID" => "ab9d1dd6-52ea-4acf-bb29-06f2da959f33", "OrderItems" => $itemList, "OrderType" => $chosen_shipping_id, "RequiredDate" => '22/12/2015', "RequiredTime" => $collection_time, "Name" => $customer_name, "DeliveryAddress" => $shipping_address, "DeliveryPostcode" => $shipping_postcode, "TelNo" => $phone, "Email" => $email, "DeliveryInstructions" => $comment, "DeliveryCost" => $shipping_fee, "Payment" => array("PaymentType" => "4", "TransactionID" => $transaction_id), "OrderTotal" => $cartTotal);
var_dump($jsonValue);
?>
</pre>
<?php
get_footer();
示例14: sendCustomerInvoice
//.........这里部分代码省略.........
<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">
<span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_total_discount()) . '</span>
</font>
</td>
</tr>';
}
$invoice_mail_content .= '<tr>
<th scope="row" colspan="2">
<font align="left">Tax:</font>
</th>
<td>
<font align="left">
<span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_cart_tax() + $wooCommerceOrderObject->get_shipping_tax()) . '</span>
</font>
</td>
</tr>
<tr>
<th scope="row" colspan="2">
<font align="left">Shipping:</font>
</th>
<td>
<font align="left">
<span class="amount">$' . $wooCommerceOrderObject->get_total_shipping() . '</span> <small>via ' . $wooCommerceOrderObject->get_shipping_method() . '</small>
</font>
</td>
</tr>
<tr>
<th scope="row" colspan="2">
<font align="left">Payment Method:</font>
</th>
<td>
<font align="left">' . $wooCommerceOrderObject->payment_method_title . '</font>
</td>
</tr>
<tr>
<th scope="row" colspan="2">
<font align="left">Order Total:</font>
</th>
<td>
<font align="left">
<span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_total()) . '</span>
</font>
</td>
</tr>
</tfoot>
</table>
<h2>
<font face="Arial" align="left" style="font-weight:bold;font-size:30px;color:#6d6d6d">Customer details</font>
</h2>
<p><strong>Email:</strong> ' . $customerMailId . '</p>
<p><strong>Tel:</strong> ' . $wooCommerceOrderObject->billing_phone . '</p>
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td valign="top" width="50%">