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


PHP WC_Order_Item_Meta类代码示例

本文整理汇总了PHP中WC_Order_Item_Meta的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order_Item_Meta类的具体用法?PHP WC_Order_Item_Meta怎么用?PHP WC_Order_Item_Meta使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WC_Order_Item_Meta类的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 
}
开发者ID:siwvolunteers,项目名称:siw,代码行数:32,代码来源:siw-woocommerce-email.php

示例2: output_csv

 /**
  * Sort the data for CSV output first
  *
  * @param int   $product_id
  * @param array $headers
  * @param array $body
  * @param array $items
  */
 public static function output_csv($product_id, $headers, $body, $items)
 {
     $headers['quantity'] = __('Quantity', 'wcvendors');
     $new_body = array();
     foreach ($body as $i => $order) {
         // Remove comments
         unset($body[$i]['comments']);
         // Remove all numeric keys in each order (these are the meta values we are redoing into new lines)
         foreach ($order as $key => $col) {
             if (is_int($key)) {
                 unset($order[$key]);
             }
         }
         // New order row
         $new_row = $body[$i];
         // Remove order to redo
         unset($body[$i]);
         foreach ($items[$i]['items'] as $item) {
             $item_meta = new WC_Order_Item_Meta($item['item_meta']);
             $item_meta_options = $item_meta->get_formatted();
             // $item_meta = $item_meta->display( true, true );
             $new_row_with_meta = $new_row;
             if (sizeof($item_meta_options) > 0) {
                 $new_row_with_meta[] = $item['qty'];
                 foreach ($item_meta_options as $item_meta_option) {
                     if (!array_key_exists($item_meta_option['label'], $headers)) {
                         $headers[$item_meta_option['label']] = $item_meta_option['label'];
                     }
                     $new_row_with_meta[] = $item_meta_option['value'];
                 }
             } else {
                 $new_row_with_meta[] = $item['qty'];
             }
             $new_body[] = $new_row_with_meta;
         }
     }
     $headers = apply_filters('wcvendors_csv_headers', $headers, $product_id, $items);
     $body = apply_filters('wcvendors_csv_body', $new_body, $product_id, $items);
     WCV_Export_CSV::download($headers, $body, $product_id);
 }
开发者ID:oleggen,项目名称:wcvendors,代码行数:48,代码来源:class-export-csv.php

示例3: add_order_item_meta

 /**
  * Add each subscription product's details to an order so that the state of the subscription persists even when a product is changed
  *
  * @since 1.2
  */
 public static function add_order_item_meta($order_item)
 {
     global $woocommerce;
     if (WC_Subscriptions_Product::is_subscription($order_item['id'])) {
         // Make sure existing meta persists
         $item_meta = new WC_Order_Item_Meta($order_item['item_meta']);
         // Add subscription details so order state persists even when a product is changed
         $item_meta->add('_subscription_period', WC_Subscriptions_Product::get_period($order_item['id']));
         $item_meta->add('_subscription_interval', WC_Subscriptions_Product::get_interval($order_item['id']));
         $item_meta->add('_subscription_length', WC_Subscriptions_Product::get_length($order_item['id']));
         $item_meta->add('_subscription_trial_length', WC_Subscriptions_Product::get_trial_length($order_item['id']));
         $item_meta->add('_subscription_trial_period', WC_Subscriptions_Product::get_trial_period($order_item['id']));
         $item_meta->add('_subscription_recurring_amount', $woocommerce->cart->base_recurring_prices[$order_item['id']]);
         // WC_Subscriptions_Product::get_price() would return a price without filters applied
         $item_meta->add('_subscription_sign_up_fee', WC_Subscriptions_Product::get_sign_up_fee($order_item['id']));
         // Calculated recurring amounts for the item
         $item_meta->add('_recurring_line_total', $woocommerce->cart->recurring_cart_contents[$order_item['id']]['recurring_line_total']);
         $item_meta->add('_recurring_line_tax', $woocommerce->cart->recurring_cart_contents[$order_item['id']]['recurring_line_tax']);
         $item_meta->add('_recurring_line_subtotal', $woocommerce->cart->recurring_cart_contents[$order_item['id']]['recurring_line_subtotal']);
         $item_meta->add('_recurring_line_subtotal_tax', $woocommerce->cart->recurring_cart_contents[$order_item['id']]['recurring_line_subtotal_tax']);
         $order_item['item_meta'] = $item_meta->meta;
     }
     return $order_item;
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:29,代码来源:class-wc-subscriptions-checkout.php

示例4: 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();
 }
开发者ID:danisdead,项目名称:gastrointernacional,代码行数:10,代码来源:abstract-wc-order.php

示例5: WC_Order_Item_Meta

        }
        ?>
					<?php 
        $order_item = WC_Subscriptions_Order::get_item_by_product_id($order, $subscription_details['product_id']);
        ?>
					<?php 
        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>
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:31,代码来源:my-subscriptions.php

示例6: foreach

<?php

/**
 * Email Order Items
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates/Emails
 * @version     2.1.2
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
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);
    if (apply_filters('woocommerce_order_item_visible', true, $item)) {
        ?>
		<tr>
			<td style="text-align:left; vertical-align:middle; border: 1px solid #eee; word-wrap:break-word;"><?php 
        // Show title/image etc
        if ($show_image) {
            echo apply_filters('woocommerce_order_item_thumbnail', '<img src="' . ($_product->get_image_id() ? current(wp_get_attachment_image_src($_product->get_image_id(), 'thumbnail')) : wc_placeholder_img_src()) . '" alt="' . __('Product Image', 'woocommerce') . '" height="' . esc_attr($image_size[1]) . '" width="' . esc_attr($image_size[0]) . '" style="vertical-align:middle; margin-right: 10px;" />', $item);
        }
        // Product name
        echo apply_filters('woocommerce_order_item_name', $item['name'], $item);
        // SKU
        if ($show_sku && is_object($_product) && $_product->get_sku()) {
            echo ' (#' . $_product->get_sku() . ')';
        }
        // allow other plugins to add additional product information here
开发者ID:venkateshphp,项目名称:intellitraining,代码行数:31,代码来源:email-order-items.php

示例7: _e

                <th class="product-total"><?php 
_e('Total', 'woocommerce');
?>
</th>
            </tr>
        </thead>
       
        <tbody>
            <?php 
if (sizeof($order->get_items()) > 0) {
    foreach ($order->get_items() as $item) {
        $_product = get_product($item['variation_id'] ? $item['variation_id'] : $item['product_id']);
        echo '
					<tr class = "' . esc_attr(apply_filters('woocommerce_order_table_item_class', 'order_table_item', $item, $order)) . '">
						<td class="product-name">' . apply_filters('woocommerce_order_table_product_title', '<a href="' . get_permalink($item['product_id']) . '">' . $item['name'] . '</a>', $item) . ' ' . apply_filters('woocommerce_order_table_item_quantity', '<strong class="product-quantity">&times; ' . $item['qty'] . '</strong>', $item);
        $item_meta = new WC_Order_Item_Meta($item['item_meta']);
        $item_meta->display();
        if ($_product && $_product->exists() && $_product->is_downloadable() && $order->is_download_permitted()) {
            $download_file_urls = $order->get_downloadable_file_urls($item['product_id'], $item['variation_id'], $item);
            $i = 0;
            $links = array();
            foreach ($download_file_urls as $file_url => $download_file_url) {
                $filename = woocommerce_get_filename_from_url($file_url);
                $links[] = '<small><a href="' . $download_file_url . '">' . sprintf(__('Download file%s', 'woocommerce'), count($download_file_urls) > 1 ? ' ' . ($i + 1) . ': ' : ': ') . $filename . '</a></small>';
                $i++;
            }
            echo implode('<br/>', $links);
        }
        echo '</td><td class="product-total">' . $order->get_formatted_line_subtotal($item) . '</td></tr>';
        // Show any purchase notes
        if ($order->status == 'completed' || $order->status == 'processing') {
开发者ID:rongandat,项目名称:sallumeh,代码行数:31,代码来源:order-details.php

示例8: 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;
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:66,代码来源:class-wc-freshbooks-api-request.php

示例9: 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;
 }
开发者ID:slavic18,项目名称:cats,代码行数:15,代码来源:class-wc-gateway-paypal-request.php

示例10: get_order_refund

 /**
  * Get an order refund for the given order ID and ID
  *
  * @since 2.2
  * @param string $order_id order ID
  * @param string|null $fields fields to limit response to
  * @return array
  */
 public function get_order_refund($order_id, $id, $fields = null)
 {
     try {
         // Validate order ID
         $order_id = $this->validate_request($order_id, $this->post_type, 'read');
         if (is_wp_error($order_id)) {
             return $order_id;
         }
         $id = absint($id);
         if (empty($id)) {
             throw new WC_API_Exception('woocommerce_api_invalid_order_refund_id', __('Invalid order refund ID', 'woocommerce'), 400);
         }
         $order = wc_get_order($id);
         $refund = wc_get_order($id);
         if (!$refund) {
             throw new WC_API_Exception('woocommerce_api_invalid_order_refund_id', __('An order refund with the provided ID could not be found', 'woocommerce'), 404);
         }
         $line_items = array();
         // Add line items
         foreach ($refund->get_items('line_item') as $item_id => $item) {
             $product = $order->get_product_from_item($item);
             $meta = new WC_Order_Item_Meta($item, $product);
             $item_meta = array();
             foreach ($meta->get_formatted() as $meta_key => $formatted_meta) {
                 $item_meta[] = array('key' => $meta_key, 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value']);
             }
             $line_items[] = array('id' => $item_id, 'subtotal' => wc_format_decimal($order->get_line_subtotal($item), 2), 'subtotal_tax' => wc_format_decimal($item['line_subtotal_tax'], 2), 'total' => wc_format_decimal($order->get_line_total($item), 2), 'total_tax' => wc_format_decimal($order->get_line_tax($item), 2), 'price' => wc_format_decimal($order->get_item_total($item), 2), 'quantity' => (int) $item['qty'], 'tax_class' => !empty($item['tax_class']) ? $item['tax_class'] : null, 'name' => $item['name'], 'product_id' => isset($product->variation_id) ? $product->variation_id : $product->id, 'sku' => is_object($product) ? $product->get_sku() : null, 'meta' => $item_meta, 'refunded_item_id' => (int) $item['refunded_item_id']);
         }
         $order_refund = array('id' => $refund->id, 'created_at' => $this->server->format_datetime($refund->date), 'amount' => wc_format_decimal($refund->get_refund_amount(), 2), 'reason' => $refund->get_refund_reason(), 'line_items' => $line_items);
         return array('order_refund' => apply_filters('woocommerce_api_order_refund_response', $order_refund, $id, $fields, $refund, $order_id, $this));
     } catch (WC_API_Exception $e) {
         return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
     }
 }
开发者ID:Geers,项目名称:woocommerce,代码行数:42,代码来源:class-wc-api-orders.php

示例11: get_order_items

 /**
  * Get the current order items
  */
 public function get_order_items()
 {
     global $woocommerce;
     global $_product;
     $items = $this->order->get_items();
     $data_list = array();
     if (sizeof($items) > 0) {
         foreach ($items as $item_id => $item) {
             // Array with data for the pdf template
             $data = array();
             // Set the item_id
             $data['item_id'] = $item_id;
             // Set the id
             $data['product_id'] = $item['product_id'];
             $data['variation_id'] = $item['variation_id'];
             // Set item name
             $data['name'] = $item['name'];
             // Set item quantity
             $data['quantity'] = $item['qty'];
             // Set the line total (=after discount)
             $data['line_total'] = $this->wc_price($item['line_total']);
             $data['single_line_total'] = $this->wc_price($item['line_total'] / max(1, $item['qty']));
             $data['line_tax'] = $this->wc_price($item['line_tax']);
             $data['single_line_tax'] = $this->wc_price($item['line_tax'] / max(1, $item['qty']));
             $line_tax_data = maybe_unserialize(isset($item['line_tax_data']) ? $item['line_tax_data'] : '');
             $data['tax_rates'] = $this->get_tax_rate($item['tax_class'], $item['line_total'], $item['line_tax'], $line_tax_data);
             // Set the line subtotal (=before discount)
             $data['line_subtotal'] = $this->wc_price($item['line_subtotal']);
             $data['line_subtotal_tax'] = $this->wc_price($item['line_subtotal_tax']);
             $data['ex_price'] = $this->get_formatted_item_price($item, 'total', 'excl');
             $data['price'] = $this->get_formatted_item_price($item, 'total');
             $data['order_price'] = $this->order->get_formatted_line_subtotal($item);
             // formatted according to WC settings
             // Calculate the single price with the same rules as the formatted line subtotal (!)
             // = before discount
             $data['ex_single_price'] = $this->get_formatted_item_price($item, 'single', 'excl');
             $data['single_price'] = $this->get_formatted_item_price($item, 'single');
             // Pass complete item array
             $data['item'] = $item;
             // Create the product to display more info
             $data['product'] = null;
             $product = $this->order->get_product_from_item($item);
             // Checking fo existance, thanks to MDesigner0
             if (!empty($product)) {
                 // Set the thumbnail id DEPRICATED (does not support thumbnail sizes), use thumbnail_path or thumbnail instead
                 $data['thumbnail_id'] = $this->get_thumbnail_id($product);
                 // Thumbnail (full img tag)
                 $data['thumbnail'] = $this->get_thumbnail($product);
                 // Set the single price (turned off to use more consistent calculated price)
                 // $data['single_price'] = woocommerce_price ( $product->get_price() );
                 // Set item SKU
                 $data['sku'] = $product->get_sku();
                 // Set item weight
                 $data['weight'] = $product->get_weight();
                 // Set item dimensions
                 $data['dimensions'] = $product->get_dimensions();
                 // Pass complete product object
                 $data['product'] = $product;
             }
             // Set item meta
             if (version_compare(WOOCOMMERCE_VERSION, '2.4', '<')) {
                 $meta = new WC_Order_Item_Meta($item['item_meta'], $product);
             } else {
                 // pass complete item for WC2.4+
                 $meta = new WC_Order_Item_Meta($item, $product);
             }
             $data['meta'] = $meta->display(false, true);
             $data_list[$item_id] = apply_filters('wpo_wcpdf_order_item_data', $data, $this->order);
         }
     }
     return apply_filters('wpo_wcpdf_order_items_data', $data_list, $this->order);
 }
开发者ID:jarsgt,项目名称:woocommerce-pdf-invoices-packing-slips,代码行数:75,代码来源:class-wcpdf-export.php

示例12: _e

                <th><?php 
    _e('Quantity', 'wc_shipping_multiple_address');
    ?>
</th>
            </tr>
            </thead>
            <tbody>
            <?php 
    foreach ($shipment->get_items() as $item) {
        // get the product; if this variation or product has been deleted, this will return null...
        $_product = $shipment->get_product_from_item($item);
        $sku = $variation = '';
        if ($_product) {
            $sku = $_product->get_sku();
        }
        $item_meta = new WC_Order_Item_Meta($item['item_meta']);
        // first, is there order item meta avaialble to display?
        $variation = $item_meta->display(true, true);
        if (!$variation && $_product && isset($_product->variation_data)) {
            // otherwise (for an order added through the admin) lets display the formatted variation data so we have something to fall back to
            $variation = wc_get_formatted_variation($_product->variation_data, true);
        }
        if ($variation) {
            $variation = '<br/><small>' . $variation . '</small>';
        }
        ?>
                <tr>
                    <td><?php 
        echo apply_filters('woocommerce_order_product_title', $item['name'], $_product) . $variation;
        ?>
</td>
开发者ID:RainyDayMedia,项目名称:carbide-probes,代码行数:31,代码来源:order-shipment-metabox.php

示例13: get_legacy_single_column_line_item

 /**
  * Get the order data format for a single column for all line items, compatible with the legacy (pre 3.0) CSV Export format
  *
  * Note this code was adapted from the old code to maintain compatibility as close as possible, so it should
  * not be modified unless absolutely necessary
  *
  * @since 3.0
  * @param array $order_data an array of order data for the given order
  * @param WC_Order $order the WC_Order object
  * @return array modified order data
  */
 private function get_legacy_single_column_line_item($order_data, WC_Order $order)
 {
     $line_items = array();
     foreach ($order->get_items() as $_ => $item) {
         $product = $order->get_product_from_item($item);
         if (!is_object($product)) {
             $product = new WC_Product(0);
         }
         $line_item = $item['name'];
         if ($product->get_sku()) {
             $line_item .= ' (' . $product->get_sku() . ')';
         }
         $line_item .= ' x' . $item['qty'];
         $item_meta = new WC_Order_Item_Meta($item);
         $variation = $item_meta->display(true, true);
         if ($variation) {
             $line_item .= ' - ' . str_replace(array("\r", "\r\n", "\n"), '', $variation);
         }
         $line_items[] = str_replace(array('&#8220;', '&#8221;'), '', $line_item);
     }
     $order_data['order_items'] = implode('; ', $line_items);
     // convert country codes to full name
     if (isset(WC()->countries->countries[$order->billing_country])) {
         $order_data['billing_country'] = WC()->countries->countries[$order->billing_country];
     }
     if (isset(WC()->countries->countries[$order->shipping_country])) {
         $order_data['shipping_country'] = WC()->countries->countries[$order->shipping_country];
     }
     // set order ID to order number
     $order_data['order_id'] = ltrim($order->get_order_number(), _x('#', 'hash before the order number', 'woocommerce-customer-order-csv-export'));
     return $order_data;
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:43,代码来源:class-wc-customer-order-csv-export-compatibility.php

示例14: calculate

 public static function calculate($order, $send_items = false)
 {
     $PaymentOrderItems = array();
     $ctr = $giftwrapamount = $total_items = $total_discount = $total_tax = $shipping = 0;
     $ITEMAMT = 0;
     if ($order) {
         $order_total = $order->get_total();
         $items = $order->get_items();
         /*
          * 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();
         }
         if ('yes' === get_option('woocommerce_calc_taxes') && 'yes' === get_option('woocommerce_prices_include_tax')) {
             $tax = $order->get_total_tax();
         }
     } else {
         //if empty order we get data from cart
         $order_total = WC()->cart->total;
         $items = WC()->cart->get_cart();
         /**
          * Get shipping and tax.
          */
         if (get_option('woocommerce_prices_include_tax') == 'yes') {
             $shipping = WC()->cart->shipping_total + WC()->cart->shipping_tax_total;
             $tax = 0;
         } else {
             $shipping = WC()->cart->shipping_total;
             $tax = WC()->cart->get_taxes_total();
         }
         if ('yes' === get_option('woocommerce_calc_taxes') && 'yes' === get_option('woocommerce_prices_include_tax')) {
             $tax = WC()->cart->get_taxes_total();
         }
     }
     if ($send_items) {
         foreach ($items as $item) {
             /*
              * Get product data from WooCommerce
              */
             if ($order) {
                 $_product = $order->get_product_from_item($item);
                 $qty = absint($item['qty']);
                 $item_meta = new WC_Order_Item_Meta($item, $_product);
                 $meta = $item_meta->display(true, true);
             } else {
                 $_product = $item['data'];
                 $qty = absint($item['quantity']);
                 $meta = WC()->cart->get_item_data($item, true);
             }
             $sku = $_product->get_sku();
             $item['name'] = html_entity_decode($_product->get_title(), ENT_NOQUOTES, 'UTF-8');
             if ($_product->product_type == 'variation') {
                 if (empty($sku)) {
                     $sku = $_product->parent->get_sku();
                 }
                 if (!empty($meta)) {
                     $item['name'] .= " - " . str_replace(", \n", " - ", $meta);
                 }
             }
             $Item = array('name' => $item['name'], 'desc' => '', 'amt' => self::round($item['line_subtotal'] / $qty), 'number' => $sku, 'qty' => $qty);
             array_push($PaymentOrderItems, $Item);
             $ITEMAMT += self::round($item['line_subtotal'] / $qty) * $qty;
         }
         /**
          * Add custom Woo cart fees as line items
          */
         foreach (WC()->cart->get_fees() as $fee) {
             $Item = array('name' => $fee->name, 'desc' => '', 'amt' => self::number_format($fee->amount, 2, '.', ''), 'number' => $fee->id, 'qty' => 1);
             /**
              * 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 += self::round($fee->amount);
             } else {
                 $giftwrapamount = self::round($fee->amount);
             }
             $ctr++;
         }
         //caculate discount
         if ($order) {
             if (!AngellEYE_Gateway_Paypal::is_wc_version_greater_2_3()) {
                 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' => '-' . self::number_format(WC()->cart->coupon_discount_amounts[$code]));
                         array_push($PaymentOrderItems, $Item);
                     }
                     $total_discount -= $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' => '-' . self::number_format(WC()->cart->coupon_discount_amounts[$code]));
                         array_push($PaymentOrderItems, $Item);
//.........这里部分代码省略.........
开发者ID:610152753,项目名称:paypal-woocommerce,代码行数:101,代码来源:paypal-for-woocommerce.php

示例15: 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 &rarr;</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) {
//.........这里部分代码省略.........
开发者ID:ujam-dev,项目名称:paypal-woocommerce,代码行数:101,代码来源:wc-gateway-paypal-express-angelleye.php


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