/**
  * Add a fee to the order.
  * Order must be saved prior to adding items.
  * @param object $fee
  * @return int updated order item ID
  */
 public function add_fee($fee)
 {
     _deprecated_function('WC_Order::add_fee', '2.7', 'Create new WC_Order_Item_Fee object and add to order with WC_Order::add_item()');
     $item = new WC_Order_Item_Fee(array('name' => $fee->name, 'tax_class' => $fee->taxable ? $fee->tax_class : 0, 'total' => $fee->amount, 'total_tax' => $fee->tax, 'taxes' => array('total' => $fee->tax_data), 'order_id' => $this->get_id()));
     $item->save();
     $this->add_item($item);
     wc_do_deprecated_action('woocommerce_order_add_fee', array($this->get_id(), $item->get_id(), $fee), '2.7', 'Use woocommerce_new_order_item action instead.');
     return $item->get_id();
 }
예제 #2
0
 /**
  * Add a product line item to the order. This is the only line item type with
  * it's own method because it saves looking up order amounts (costs are added up for you).
  * @param  \WC_Product $product
  * @param  int $qty
  * @param  array $args
  * @return int order item ID
  * @throws WC_Data_Exception
  */
 public function add_product($product, $qty = 1, $args = array())
 {
     if ($product) {
         $default_args = array('name' => $product->get_title(), 'tax_class' => $product->get_tax_class(), 'product_id' => $product->get_id(), 'variation_id' => isset($product->variation_id) ? $product->variation_id : 0, 'variation' => isset($product->variation_id) ? $product->get_variation_attributes() : array(), 'subtotal' => $product->get_price_excluding_tax($qty), 'total' => $product->get_price_excluding_tax($qty), 'quantity' => $qty);
     } else {
         $default_args = array('quantity' => $qty);
     }
     $args = wp_parse_args($args, $default_args);
     // BW compatibility with old args
     if (isset($args['totals'])) {
         foreach ($args['totals'] as $key => $value) {
             if ('tax' === $key) {
                 $args['total_tax'] = $value;
             } elseif ('tax_data' === $key) {
                 $args['taxes'] = $value;
             } else {
                 $args[$key] = $value;
             }
         }
     }
     $item = new WC_Order_Item_Product($args);
     $item->set_backorder_meta();
     $item->set_order_id($this->get_id());
     $item->save();
     $this->add_item($item);
     wc_do_deprecated_action('woocommerce_order_add_product', array($this->get_id(), $item->get_id(), $product, $qty, $args), '2.7', 'Use woocommerce_new_order_item action instead.');
     return $item->get_id();
 }
    ?>
_tab <?php 
    echo implode(' ', (array) $tab['class']);
    ?>
">
				<a href="#<?php 
    echo $tab['target'];
    ?>
"><?php 
    echo esc_html($tab['label']);
    ?>
</a>
			</li>
		<?php 
}
?>
		<?php 
do_action('woocommerce_product_write_panel_tabs');
?>
	</ul>

	<?php 
self::output_tabs();
self::output_variations();
do_action('woocommerce_product_data_panels');
wc_do_deprecated_action('woocommerce_product_write_panels', array(), '2.6', 'Use woocommerce_product_data_panels action instead.');
wp_nonce_field('woocommerce_save_data', 'woocommerce_meta_nonce');
?>
	<div class="clear"></div>
</div>