本文整理汇总了PHP中WC_Order_Item_Meta::display方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order_Item_Meta::display方法的具体用法?PHP WC_Order_Item_Meta::display怎么用?PHP WC_Order_Item_Meta::display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Order_Item_Meta
的用法示例。
在下文中一共展示了WC_Order_Item_Meta::display方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: siw_wc_email_show_project_details
function siw_wc_email_show_project_details($order, $application_number)
{
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php
siw_wc_generate_email_table_header_row('Aanmelding');
siw_wc_generate_email_table_row('Aanmeldnummer', $application_number);
foreach ($order->get_items() as $item_id => $item) {
$_product = apply_filters('woocommerce_order_item_product', $order->get_product_from_item($item), $item);
$item_meta = new WC_Order_Item_Meta($item, $_product);
//projectdetails formatteren
$item_details = apply_filters('woocommerce_order_item_name', $item['name'], $item) . ' (' . get_post_meta($_product->id, 'projectduur', true) . ')';
if ($item_meta->meta) {
$item_details .= '<br/><small>' . nl2br($item_meta->display(true, true, '_', "\n")) . '</small>';
}
siw_wc_generate_email_table_row('Project', $item_details);
}
$discount = $order->get_total_discount();
$subtotal = $order->get_subtotal();
$total = $order->get_total();
//subtotaal alleen tonen als het afwijkt van het totaal
if ($subtotal != $total) {
siw_wc_generate_email_table_row('Subtotaal', $order->get_subtotal_to_display());
siw_wc_generate_email_table_row('Korting', '-' . $order->get_discount_to_display());
}
siw_wc_generate_email_table_row('Totaal', $order->get_formatted_order_total());
siw_wc_generate_email_table_row('Betaalwijze', $order->payment_method_title);
?>
</table>
<?php
}
示例2: get_order_items
/**
* Get order items.
*
* @param WC_Order $order Order data.
*
* @return array Items list, extra amount and shipping cost.
*/
protected function get_order_items($order)
{
$items = array();
$extra_amount = 0;
$shipping_cost = 0;
// Force only one item.
if ('yes' == $this->gateway->send_only_total) {
$items[] = array('description' => $this->sanitize_description(sprintf(__('Order %s', 'woocommerce-pagseguro'), $order->get_order_number())), 'amount' => $this->money_format($order->get_total()), 'quantity' => 1);
} else {
// Products.
if (0 < count($order->get_items())) {
foreach ($order->get_items() as $order_item) {
if ($order_item['qty']) {
$item_name = $order_item['name'];
if (defined('WC_VERSION') && version_compare(WC_VERSION, '2.4.0', '<')) {
$item_meta = new WC_Order_Item_Meta($order_item['item_meta']);
} else {
$item_meta = new WC_Order_Item_Meta($order_item);
}
if ($meta = $item_meta->display(true, true)) {
$item_name .= ' - ' . $meta;
}
$items[] = array('description' => $this->sanitize_description($item_name), 'amount' => $this->money_format($order->get_item_total($order_item, false)), 'quantity' => $order_item['qty']);
}
}
}
// Fees.
if (0 < count($order->get_fees())) {
foreach ($order->get_fees() as $fee) {
$items[] = array('description' => $this->sanitize_description($fee['name']), 'amount' => $this->money_format($fee['line_total']), 'quantity' => 1);
}
}
// Taxes.
if (0 < count($order->get_taxes())) {
foreach ($order->get_taxes() as $tax) {
$items[] = array('description' => $this->sanitize_description($tax['label']), 'amount' => $this->money_format($tax['tax_amount'] + $tax['shipping_tax_amount']), 'quantity' => 1);
}
}
// Shipping Cost.
if (0 < $order->get_total_shipping()) {
$shipping_cost = $this->money_format($order->get_total_shipping());
}
// Discount.
if (defined('WC_VERSION') && version_compare(WC_VERSION, '2.3', '<')) {
if (0 < $order->get_order_discount()) {
$extra_amount = '-' . $this->money_format($order->get_order_discount());
}
}
}
return array('items' => $items, 'extra_amount' => $extra_amount, 'shipping_cost' => $shipping_cost);
}
示例3: display_item_meta
/**
* Display meta data belonging to an item
* @param array $item
*/
public function display_item_meta($item)
{
$product = $this->get_product_from_item($item);
$item_meta = new WC_Order_Item_Meta($item, $product);
$item_meta->display();
}
示例4:
if (WC_Subscriptions::is_woocommerce_pre('2.4')) {
?>
<?php
$item_meta = new WC_Order_Item_Meta($order_item['item_meta'], $product);
?>
<?php
} else {
?>
<?php
$item_meta = new WC_Order_Item_Meta($order_item, $product);
?>
<?php
}
?>
<?php
$meta_to_display = $item_meta->display(true, true);
?>
<?php
if (!empty($meta_to_display)) {
?>
<p>
<?php
echo $meta_to_display;
?>
</p>
<?php
}
?>
</td>
<td class="subscription-status" style="text-align:left; white-space:nowrap;" data-title="<?php
_e('Status', 'woocommerce-subscriptions');
示例5: foreach
?>
<?php
}
if ($i != 0) {
echo "<span>Y</span>";
} else {
echo "<span>N</span>";
}
?>
</small>
<?php
}
//Added New For Add Location End
// Variation
if ($item_meta->meta) {
echo '<br/><small>' . nl2br($item_meta->display(true, true, '_', "\n")) . '</small>';
}
// File URLs
if ($show_download_links && is_object($_product) && $_product->exists() && $_product->is_downloadable()) {
$download_files = $order->get_item_downloads($item);
$i = 0;
foreach ($download_files as $download_id => $file) {
$i++;
if (count($download_files) > 1) {
$prefix = sprintf(__('Download %d', 'woocommerce'), $i);
} elseif ($i == 1) {
$prefix = __('Download', 'woocommerce');
}
echo '<br/><small>' . $prefix . ': <a href="' . esc_url($file['download_url']) . '" target="_blank">' . esc_html($file['name']) . '</a></small>';
}
}
示例6: get_invoice_lines
/**
* Get the invoice line items for a given order. This includes:
*
* + Products, mapped as FreshBooks items when the admin has linked them
* + Fees, mapped as a `Fee` item
* + Shipping, mapped as a `Shipping` item
* + Taxes, mapped using the tax code as the item
*
* Note that taxes cannot be added per-product as WooCommerce doesn't provide
* any way to get individual tax information per product and FreshBooks requires
* a tax name/percentage to be set on a per-product basis. Further, FreshBooks
* only allows 2 taxes per product where realistically most stores will have
* more
*
* @param \WC_FreshBooks_Order $order order instance
* @return array line items
* @since 3.0
*/
private function get_invoice_lines(WC_FreshBooks_Order $order)
{
$line_items = array();
// add products
foreach ($order->get_items() as $item_key => $item) {
$product = $order->get_product_from_item($item);
// must be a valid product
if (is_object($product)) {
$product_id = $product->is_type('variation') ? $product->variation_id : $product->id;
$item_name = metadata_exists('post', $product_id, '_wc_freshbooks_item_name') ? get_post_meta($product_id, '_wc_freshbooks_item_name', true) : $product->get_sku();
$item_meta = new WC_Order_Item_Meta(SV_WC_Plugin_Compatibility::is_wc_version_gte_2_4() ? $item : $item['item_meta']);
// variation data, item meta, etc
$meta = $item_meta->display(true, true);
// grouped products include a &arr; in the name which must be converted back to an arrow
$item_description = html_entity_decode($product->get_title(), ENT_QUOTES, 'UTF-8') . ($meta ? sprintf(' (%s)', $meta) : '');
} else {
$item_name = __('Product', WC_FreshBooks::TEXT_DOMAIN);
$item_description = $item['name'];
}
$line_items[] = array('name' => $item_name, 'description' => apply_filters('wc_freshbooks_line_item_description', $item_description, $item, $order, $item_key), 'unit_cost' => $order->get_item_subtotal($item), 'quantity' => $item['qty']);
}
$coupons = $order->get_items('coupon');
// add coupons
foreach ($coupons as $coupon_item) {
$coupon = new WC_Coupon($coupon_item['name']);
$coupon_post = get_post($coupon->id);
$coupon_type = false !== strpos($coupon->type, '_cart') ? __('Cart Discount', WC_FreshBooks::TEXT_DOMAIN) : __('Product Discount', WC_FreshBooks::TEXT_DOMAIN);
$line_items[] = array('name' => $coupon_item['name'], 'description' => is_object($coupon_post) && $coupon_post->post_excerpt ? sprintf(__('%s - %s', WC_FreshBooks::TEXT_DOMAIN), $coupon_type, $coupon_post->post_excerpt) : $coupon_type, 'unit_cost' => wc_format_decimal($coupon_item['discount_amount'] * -1, 2), 'quantity' => 1);
}
// manually created orders can't have coupon items, but may have an order discount set
// which must be added as a line item
if (0 == count($coupons) && $order->get_total_discount() > 0) {
$line_items[] = array('name' => __('Order Discount', WC_FreshBooks::TEXT_DOMAIN), 'description' => __('Order Discount', WC_FreshBooks::TEXT_DOMAIN), 'unit_cost' => wc_format_decimal($order->get_total_discount() * -1, 2), 'quantity' => 1);
}
// add fees
foreach ($order->get_fees() as $fee_key => $fee) {
$line_items[] = array('name' => __('Fee', WC_FreshBooks::TEXT_DOMAIN), 'description' => $fee['name'], 'unit_cost' => $order->get_line_total($fee), 'quantity' => 1);
}
// add shipping
foreach ($order->get_shipping_methods() as $shipping_method_key => $shipping_method) {
$line_items[] = array('name' => __('Shipping', WC_FreshBooks::TEXT_DOMAIN), 'description' => ucwords(str_replace('_', ' ', $shipping_method['method_id'])), 'unit_cost' => $shipping_method['cost'], 'quantity' => 1);
}
// add taxes
foreach ($order->get_tax_totals() as $tax_code => $tax) {
$line_items[] = array('name' => $tax_code, 'description' => $tax->label, 'unit_cost' => number_Format($tax->amount, 2, '.', ''), 'quantity' => 1);
}
return $line_items;
}
示例7: get_order_item_name
/**
* Get order item names as a string
* @param WC_Order $order
* @param array $item
* @return string
*/
protected function get_order_item_name($order, $item)
{
$item_name = $item['name'];
$item_meta = new WC_Order_Item_Meta($item);
if ($meta = $item_meta->display(true, true)) {
$item_name .= ' ( ' . $meta . ' )';
}
return $item_name;
}
示例8: plain_vendor_order_item_table
/**
* plain_vendor_order_item_table function to get the plain html of item table of a vendor.
* @access public
* @param order id , vendor term id
*/
public function plain_vendor_order_item_table($order, $vendor_id, $is_ship = false)
{
global $WCMp;
require_once 'class-wcmp-calculate-commission.php';
$commission_obj = new WCMp_Calculate_Commission();
$vendor_items = $this->get_vendor_items_from_order($order->id, $vendor_id);
foreach ($vendor_items as $item_id => $item) {
$_product = apply_filters('woocommerce_order_item_product', $order->get_product_from_item($item), $item);
$item_meta = new WC_Order_Item_Meta($item['item_meta'], $_product);
// Title
echo apply_filters('woocommerce_order_item_name', $item['name'], $item);
// Variation
echo $item_meta->meta ? "\n" . $item_meta->display(true, true) : '';
// Quantity
echo "\n" . sprintf(__('Quantity: %s', $WCMp->text_domain), $item['qty']);
if (isset($item['variation_id']) && !empty($item['variation_id'])) {
$variation_id = $item['variation_id'];
}
$product_id = $item['product_id'];
if ($is_ship) {
echo "\n" . sprintf(__('Total: %s', $WCMp->text_domain), $order->get_formatted_line_subtotal($item));
} else {
echo "\n" . sprintf(__('Commission: %s', $WCMp->text_domain), $commission_obj->get_item_commission($product_id, $variation_id, $item, $order->id, $item_id));
}
echo "\n\n";
}
}
示例9: ConfirmPayment
/**
* ConfirmPayment
*
* Finalizes the checkout with PayPal's DoExpressCheckoutPayment API
*
* @FinalPaymentAmt (double) Final payment amount for the order.
*/
function ConfirmPayment($FinalPaymentAmt)
{
/*
* Display message to user if session has expired.
*/
if (sizeof(WC()->cart->get_cart()) == 0) {
$ms = sprintf(__('Sorry, your session has expired. <a href=%s>Return to homepage →</a>', 'paypal-for-woocommerce'), '"' . home_url() . '"');
$ec_confirm_message = apply_filters('angelleye_ec_confirm_message', $ms);
wc_add_notice($ec_confirm_message, "error");
}
/*
* Check if the PayPal class has already been established.
*/
if (!class_exists('Angelleye_PayPal')) {
require_once 'lib/angelleye/paypal-php-library/includes/paypal.class.php';
}
/*
* Create PayPal object.
*/
$PayPalConfig = array('Sandbox' => $this->testmode == 'yes' ? TRUE : FALSE, 'APIUsername' => $this->api_username, 'APIPassword' => $this->api_password, 'APISignature' => $this->api_signature);
$PayPal = new Angelleye_PayPal($PayPalConfig);
/*
* Get data from WooCommerce object
*/
if (!empty($this->confirm_order_id)) {
$order = new WC_Order($this->confirm_order_id);
$invoice_number = preg_replace("/[^0-9]/", "", $order->get_order_number());
if ($order->customer_note) {
$customer_notes = wptexturize($order->customer_note);
}
$shipping_first_name = $order->shipping_first_name;
$shipping_last_name = $order->shipping_last_name;
$shipping_address_1 = $order->shipping_address_1;
$shipping_address_2 = $order->shipping_address_2;
$shipping_city = $order->shipping_city;
$shipping_state = $order->shipping_state;
$shipping_postcode = $order->shipping_postcode;
$shipping_country = $order->shipping_country;
}
// Prepare request arrays
$DECPFields = array('token' => urlencode($this->get_session('TOKEN')), 'payerid' => urlencode($this->get_session('payer_id')), 'returnfmfdetails' => '', 'giftmessage' => $this->get_session('giftmessage'), 'giftreceiptenable' => $this->get_session('giftreceiptenable'), 'giftwrapname' => $this->get_session('giftwrapname'), 'giftwrapamount' => $this->get_session('giftwrapamount'), 'buyermarketingemail' => '', 'surveyquestion' => '', 'surveychoiceselected' => '', 'allowedpaymentmethod' => '');
$Payments = array();
$order_items_own = array();
$final_order_total = $order->get_order_item_totals();
$current_currency = get_woocommerce_currency_symbol(get_woocommerce_currency());
$final_order_total_amt_strip_ec = strip_tags($final_order_total['order_total']['value']);
$final_order_total_amt_strip = str_replace(',', '', $final_order_total_amt_strip_ec);
$final_order_total_amt = str_replace($current_currency, '', $final_order_total_amt_strip);
$Payment = array('amt' => number_format($final_order_total_amt, 2, '.', ''), 'currencycode' => get_woocommerce_currency(), 'shippingdiscamt' => '', 'insuranceoptionoffered' => '', 'handlingamt' => '', 'desc' => '', 'custom' => '', 'invnum' => preg_replace("/[^0-9]/", "", $this->confirm_order_id), 'notifyurl' => '', 'shiptoname' => $shipping_first_name . ' ' . $shipping_last_name, 'shiptostreet' => $shipping_address_1, 'shiptostreet2' => $shipping_address_2, 'shiptocity' => $shipping_city, 'shiptostate' => $shipping_state, 'shiptozip' => $shipping_postcode, 'shiptocountrycode' => $shipping_country, 'shiptophonenum' => '', 'notetext' => $this->get_session('customer_notes'), 'allowedpaymentmethod' => '', 'paymentaction' => $this->payment_action == 'Authorization' ? 'Authorization' : 'Sale', 'paymentrequestid' => '', 'sellerpaypalaccountid' => '', 'sellerid' => '', 'sellerusername' => '', 'sellerregistrationdate' => '', 'softdescriptor' => '');
$PaymentOrderItems = array();
$ctr = $total_items = $total_discount = $total_tax = $shipping = 0;
$ITEMAMT = 0;
$counter = 1;
if (sizeof($order->get_items()) > 0) {
// if ($this->send_items) {
foreach ($order->get_items() as $values) {
$_product = $order->get_product_from_item($values);
$qty = absint($values['qty']);
$sku = $_product->get_sku();
$values['name'] = html_entity_decode($values['name'], ENT_NOQUOTES, 'UTF-8');
if ($_product->product_type == 'variation') {
if (empty($sku)) {
$sku = $_product->parent->get_sku();
}
//$item_meta = new WC_Order_Item_Meta($values['item_meta']);
$item_meta = new WC_Order_Item_Meta($values, $_product);
$meta = $item_meta->display(true, true);
if (!empty($meta)) {
$values['name'] .= " - " . str_replace(", \n", " - ", $meta);
}
}
//////////////////////////////////////////***************************////////////////////////////////////
$lineitems_prepare = $this->prepare_line_items($order);
$lineitems = $_SESSION['line_item'];
if (in_array($values['product_id'], $lineitems)) {
$arraykey = array_search($values['product_id'], $lineitems);
$item_position = str_replace('product_number_', '', $arraykey);
$get_amountkey = 'amount_' . $counter;
$get_qtykey = 'quantity_' . $counter;
$switcher_amt = $lineitems[$get_amountkey];
$switcher_qty = $lineitems[$get_qtykey];
$counter = $counter + 1;
}
//////////////////////////////////////////***************************////////////////////////////////////
$Item = array('name' => $values['name'], 'desc' => '', 'amt' => round($switcher_amt, 2), 'number' => $sku, 'qty' => $qty, 'taxamt' => '', 'itemurl' => '', 'itemcategory' => '', 'itemweightvalue' => '', 'itemweightunit' => '', 'itemheightvalue' => '', 'itemheightunit' => '', 'itemwidthvalue' => '', 'itemwidthunit' => '', 'itemlengthvalue' => '', 'itemlengthunit' => '', 'ebayitemnumber' => '', 'ebayitemauctiontxnid' => '', 'ebayitemorderid' => '', 'ebayitemcartid' => '');
array_push($PaymentOrderItems, $Item);
$ITEMAMT += round($switcher_amt, 2) * $switcher_qty;
$order_items_own[] = round($switcher_amt, 2) * $switcher_qty;
}
/**
* Add custom Woo cart fees as line items
*/
foreach (WC()->cart->get_fees() as $fee) {
//.........这里部分代码省略.........
示例10: get_products_data
/**
* Get products data.
*
* @param WC_Order $order
*
* @return array
*/
protected function get_products_data($order)
{
$i = 1;
$data = array();
// Force only one item.
if ('yes' == $this->send_only_total || 'yes' == get_option('woocommerce_prices_include_tax')) {
$data['cart_' . $i . '_name'] = $this->sanitize_string(sprintf(__('Order %s', 'woocommerce-checkout-cielo'), $order->get_order_number()));
// $data['cart_' . $i . '_description'] = '';
$data['cart_' . $i . '_unitprice'] = $this->get_price($order->get_total()) - $this->get_price($order->get_total_shipping()) + $this->get_discount($order);
$data['cart_' . $i . '_quantity'] = '1';
$data['cart_' . $i . '_type'] = '1';
// $data['cart_' . $i . '_code'] = '';
$data['cart_' . $i . '_weight'] = '0';
} else {
if (0 < sizeof($order->get_items())) {
foreach ($order->get_items() as $order_item) {
if ($order_item['qty']) {
$item_total = $this->get_price($order->get_item_subtotal($order_item, false));
if (0 > $item_total) {
continue;
}
// Get product data.
$_product = apply_filters('woocommerce_order_item_product', $order->get_product_from_item($order_item), $order_item);
if (defined('WC_VERSION') && version_compare(WC_VERSION, '2.4.0', '<')) {
$item_meta = new WC_Order_Item_Meta($order_item['item_meta'], $_product);
} else {
$item_meta = new WC_Order_Item_Meta($order_item, $_product);
}
$data['cart_' . $i . '_name'] = $this->sanitize_string($order_item['name']);
if ($meta = $item_meta->display(true, true)) {
$data['cart_' . $i . '_description'] = $this->sanitize_string($meta, 256);
}
$data['cart_' . $i . '_unitprice'] = $item_total;
$data['cart_' . $i . '_quantity'] = $order_item['qty'];
$data['cart_' . $i . '_type'] = '1';
if ($sku = $_product->get_sku()) {
$data['cart_' . $i . '_code'] = $sku;
}
$data['cart_' . $i . '_weight'] = wc_get_weight($_product->get_weight(), 'g');
$i++;
}
}
}
// Fees.
if (0 < sizeof($order->get_fees())) {
foreach ($order->get_fees() as $fee) {
$fee_total = $this->get_price($fee['line_total']);
if (0 > $fee_total) {
continue;
}
$data['cart_' . $i . '_name'] = $this->sanitize_string($fee['name']);
$data['cart_' . $i . '_unitprice'] = $fee_total;
$data['cart_' . $i . '_quantity'] = '1';
$data['cart_' . $i . '_type'] = '4';
$i++;
}
}
// Taxes.
if (0 < sizeof($order->get_taxes())) {
foreach ($order->get_taxes() as $tax) {
$tax_total = $this->get_price($tax['tax_amount'] + $tax['shipping_tax_amount']);
if (0 > $tax_total) {
continue;
}
$data['cart_' . $i . '_name'] = $this->sanitize_string($tax['label']);
$data['cart_' . $i . '_unitprice'] = $tax_total;
$data['cart_' . $i . '_quantity'] = '1';
$data['cart_' . $i . '_type'] = '4';
$i++;
}
}
}
return $data;
}
示例11: array
//.........这里部分代码省略.........
_e('#ID Vendita', 'woocommerce');
?>
</span></th>
<th class="order-date"><span class="nobr"><?php
_e('Data', 'woocommerce');
?>
</span></th>
<th class="order-status"><span class="nobr"><?php
_e('Stato', 'woocommerce');
?>
</span></th>
<th class="order-total"><span class="nobr"><?php
_e('Totale', 'woocommerce');
?>
</span></th>
<th class="order-actions"><span class="nobr"><?php
_e('Prodotti / Attributi / Totale', 'woocommerce');
?>
</span></th>
<th class="order-actions"><span class="nobr"><?php
_e('Dettagli', 'woocommerce');
?>
</span></th>
<th class="order-actions"><span class="nobr"><?php
_e('Annullare', 'woocommerce');
?>
</span></th>
</tr>
</thead>
<style>
.hentry img { height: auto; max-width: 35%;}
.woocommerce-message { display:none;}
</style>
<tbody><?php
foreach ($customer_orders as $customer_order) {
$order = new WC_Order();
$order->populate($customer_order);
$status = get_term_by('slug', $order->status, 'shop_order_status');
$item_count = $order->get_item_count();
?>
<tr class="order">
<td class="order-number">
<a href="<?php
echo $order->get_view_order_url();
?>
">
<?php
echo $order->get_order_number();
?>
</a>
</td>
<td class="order-date">
<time datetime="<?php
echo date('Y-m-d', strtotime($order->order_date));
?>
" title="<?php
echo esc_attr(strtotime($order->order_date));
?>
"><?php
echo date_i18n(get_option('date_format'), strtotime($order->order_date));
?>
</time>
</td>
<td class="order-status" style="text-align:left; text-transform:uppercase; white-space:nowrap; color:#0C0" >
示例12: array
/**
* do_payment
*
* Process the PayFlow transaction with PayPal.
*
* @access public
* @param mixed $order
* @param mixed $card_number
* @param mixed $card_exp
* @param mixed $card_csc
* @param string $centinelPAResStatus (default: '')
* @param string $centinelEnrolled (default: '')
* @param string $centinelCavv (default: '')
* @param string $centinelEciFlag (default: '')
* @param string $centinelXid (default: '')
* @return void
*/
function do_payment($order, $card_number, $card_exp, $card_csc, $centinelPAResStatus = '', $centinelEnrolled = '', $centinelCavv = '', $centinelEciFlag = '', $centinelXid = '')
{
/*
* Display message to user if session has expired.
*/
if (sizeof(WC()->cart->get_cart()) == 0) {
wc_add_notice(sprintf(__('Sorry, your session has expired. <a href="%s">Return to homepage →</a>', 'wc-paypal-express'), home_url()), "error");
}
/*
* Check if the PayPal_PayFlow class has already been established.
*/
if (!class_exists('PayPal_PayFlow')) {
require_once 'lib/angelleye/paypal-php-library/includes/paypal.class.php';
require_once 'lib/angelleye/paypal-php-library/includes/paypal.payflow.class.php';
}
/**
* Create PayPal_PayFlow object.
*/
$PayPalConfig = array('Sandbox' => $sandbox, 'APIUsername' => $this->paypal_user, 'APIPassword' => trim($this->paypal_password), 'APIVendor' => $this->paypal_vendor, 'APIPartner' => $this->paypal_partner);
$PayPal = new PayPal_PayFlow($PayPalConfig);
/**
* Pulled from original Woo extension.
*/
if (empty($GLOBALS['wp_rewrite'])) {
$GLOBALS['wp_rewrite'] = new WP_Rewrite();
}
$this->add_log($order->get_checkout_order_received_url());
try {
/**
* Parameter set by original Woo. I can probably ditch this, but leaving it for now.
*/
$url = $this->testmode == 'yes' ? $this->testurl : $this->liveurl;
/**
* PayPal PayFlow Gateway Request Params
*/
$PayPalRequestData = array('tender' => 'C', 'trxtype' => 'S', 'acct' => $card_number, 'expdate' => $card_exp, 'amt' => $order->get_total(), 'currency' => get_option('woocommerce_currency'), 'dutyamt' => '', 'freightamt' => '', 'taxamt' => '', 'taxexempt' => '', 'comment1' => $order->customer_note ? wptexturize($order->customer_note) : '', 'comment2' => '', 'cvv2' => $card_csc, 'recurring' => '', 'swipe' => '', 'orderid' => preg_replace("/[^0-9,.]/", "", $order->get_order_number()), 'orderdesc' => 'Order ' . $order->get_order_number() . ' on ' . get_bloginfo('name'), 'billtoemail' => $order->billing_email, 'billtophonenum' => '', 'billtofirstname' => $order->billing_first_name, 'billtomiddlename' => '', 'billtolastname' => $order->billing_last_name, 'billtostreet' => $order->billing_address_1 . ' ' . $order->billing_address_2, 'billtocity' => $order->billing_city, 'billtostate' => $order->billing_state, 'billtozip' => $order->billing_postcode, 'billtocountry' => $order->billing_country, 'origid' => '', 'custref' => '', 'custcode' => '', 'custip' => $this->get_user_ip(), 'invnum' => str_replace("#", "", $order->get_order_number()), 'ponum' => '', 'starttime' => '', 'endtime' => '', 'securetoken' => '', 'partialauth' => '', 'authcode' => '');
/**
* Shipping info
*/
if ($order->shipping_address_1) {
$PayPalRequestData['SHIPTOFIRSTNAME'] = $order->shipping_first_name;
$PayPalRequestData['SHIPTOLASTNAME'] = $order->shipping_last_name;
$PayPalRequestData['SHIPTOSTREET'] = $order->shipping_address_1 . ' ' . $order->shipping_address_2;
$PayPalRequestData['SHIPTOCITY'] = $order->shipping_city;
$PayPalRequestData['SHIPTOSTATE'] = $order->shipping_state;
$PayPalRequestData['SHIPTOCOUNTRY'] = $order->shipping_country;
$PayPalRequestData['SHIPTOZIP'] = $order->shipping_postcode;
}
/* Send Item details */
$item_loop = 0;
if (sizeof($order->get_items()) > 0) {
$ITEMAMT = 0;
foreach ($order->get_items() as $item) {
$item['name'] = html_entity_decode($item['name'], ENT_NOQUOTES, 'UTF-8');
$_product = $order->get_product_from_item($item);
if ($item['qty']) {
$sku = $_product->get_sku();
if ($_product->product_type == 'variation') {
if (empty($sku)) {
$sku = $_product->parent->get_sku();
}
$item_meta = new WC_Order_Item_Meta($item['item_meta']);
$meta = $item_meta->display(true, true);
if (!empty($meta)) {
$item['name'] .= " - " . str_replace(", \n", " - ", $meta);
}
}
if (get_option('woocommerce_prices_include_tax') == 'yes') {
$product_price = $order->get_item_subtotal($item, true, false);
} else {
$product_price = $order->get_item_subtotal($item, false, true);
}
$PayPalRequestData['L_NUMBER' . $item_loop] = $sku;
$PayPalRequestData['L_NAME' . $item_loop] = $item['name'];
$PayPalRequestData['L_COST' . $item_loop] = $product_price;
$PayPalRequestData['L_QTY' . $item_loop] = $item['qty'];
if ($sku) {
$PayPalRequestData['L_SKU' . $item_loop] = $sku;
}
$ITEMAMT += $product_price * $item['qty'];
$item_loop++;
}
}
//.........这里部分代码省略.........
示例13: foreach
/**
* Output items for display
*/
function woocommerce_pip_order_items_table($order, $show_price = FALSE)
{
$return = '';
foreach ($order->get_items() as $item) {
$_product = $order->get_product_from_item($item);
$sku = $variation = '';
$sku = $_product->get_sku();
$item_meta = new WC_Order_Item_Meta($item['item_meta']);
$variation = '<br/><small>' . $item_meta->display(TRUE, TRUE) . '</small>';
$return .= '<tr>
<td style="text-align:left; padding: 3px;">' . $sku . '</td>
<td style="text-align:left; padding: 3px;">' . apply_filters('woocommerce_order_product_title', $item['name'], $_product) . $variation . '</td>
<td style="text-align:left; padding: 3px;">' . $item['qty'] . '</td>';
if ($show_price) {
$return .= '<td style="text-align:left; padding: 3px;">';
if ($order->display_cart_ex_tax || !$order->prices_include_tax) {
$ex_tax_label = $order->prices_include_tax ? 1 : 0;
$return .= woocommerce_price($order->get_line_subtotal($item), array('ex_tax_label' => $ex_tax_label));
} else {
$return .= woocommerce_price($order->get_line_subtotal($item, TRUE));
}
$return .= '
</td>';
}
$return .= '</tr>';
}
$return = apply_filters('woocommerce_pip_order_items_table', $return);
return $return;
}
示例14: sprintf
}
foreach ($items as $item_id => $item) {
$_product = apply_filters('woocommerce_order_item_product', $order->get_product_from_item($item), $item);
$item_meta = new WC_Order_Item_Meta($item['item_meta'], $_product);
// Title
echo apply_filters('woocommerce_order_item_name', $item['name'], $item);
// SKU
if ($show_sku && $_product->get_sku()) {
echo '<br />(#' . $_product->get_sku() . ')';
}
// allow other plugins to add additional product information here
do_action('woocommerce_order_item_meta_start', $item_id, $item, $order);
// Variation
// echo $item_meta->meta ? "\n" . $item_meta->display( true, true ) : '';
if ($item_meta->meta) {
$colors = preg_replace("/#([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?\\b/", "", $item_meta->display(true, true));
$colors = str_replace('color', '', $colors);
$colors = str_replace(':', '', $colors);
echo "Color: " . $colors;
}
// Quantity
echo "\n" . sprintf(__('Quantity: %s', 'woocommerce'), $item['qty']);
// Cost
echo "\n" . sprintf(__('Cost: %s', 'woocommerce'), $order->get_formatted_line_subtotal($item));
// Download URLs
if ($show_download_links && $_product->exists() && $_product->is_downloadable()) {
$download_files = $order->get_item_downloads($item);
$i = 0;
foreach ($download_files as $download_id => $file) {
$i++;
if (count($download_files) > 1) {
示例15: 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;
}