本文整理汇总了PHP中wc_update_order_item_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_update_order_item_meta函数的具体用法?PHP wc_update_order_item_meta怎么用?PHP wc_update_order_item_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_update_order_item_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Save properties specific to this order item.
* @return int Item ID
*/
public function save()
{
parent::save();
if ($this->get_id()) {
wc_update_order_item_meta($this->get_id(), '_tax_class', $this->get_tax_class());
wc_update_order_item_meta($this->get_id(), '_tax_status', $this->get_tax_status());
wc_update_order_item_meta($this->get_id(), '_line_total', $this->get_total());
wc_update_order_item_meta($this->get_id(), '_line_tax', $this->get_total_tax());
wc_update_order_item_meta($this->get_id(), '_line_tax_data', $this->get_taxes());
}
return $this->get_id();
}
示例2: save_item_data
/**
* Saves an item's data to the database / item meta.
* Ran after both create and update, so $item->get_id() will be set.
*
* @since 2.7.0
* @param WC_Order_Item $item
*/
public function save_item_data(&$item)
{
wc_update_order_item_meta($item->get_id(), 'method_id', $item->get_method_id('edit'));
wc_update_order_item_meta($item->get_id(), 'cost', $item->get_total('edit'));
wc_update_order_item_meta($item->get_id(), 'total_tax', $item->get_total_tax('edit'));
wc_update_order_item_meta($item->get_id(), 'taxes', $item->get_taxes('edit'));
}
示例3: add_downloadlinks
/**
* @param $links
* @param $item_id
*/
function add_downloadlinks($links, $item_id)
{
if (is_array($links)) {
// add generated downloadlinks to item
wc_update_order_item_meta($item_id, '_bx_downloadlinks', $links);
}
}
示例4: save_item_data
/**
* Saves an item's data to the database / item meta.
* Ran after both create and update, so $item->get_id() will be set.
*
* @since 2.7.0
* @param WC_Order_Item $item
*/
public function save_item_data(&$item)
{
wc_update_order_item_meta($item->get_id(), '_tax_class', $item->get_tax_class('edit'));
wc_update_order_item_meta($item->get_id(), '_tax_status', $item->get_tax_status('edit'));
wc_update_order_item_meta($item->get_id(), '_line_total', $item->get_total('edit'));
wc_update_order_item_meta($item->get_id(), '_line_tax', $item->get_total_tax('edit'));
wc_update_order_item_meta($item->get_id(), '_line_tax_data', $item->get_taxes('edit'));
}
示例5: save_item_data
/**
* Saves an item's data to the database / item meta.
* Ran after both create and update, so $item->get_id() will be set.
*
* @since 2.7.0
* @param WC_Order_Item $item
*/
public function save_item_data(&$item)
{
wc_update_order_item_meta($item->get_id(), 'rate_id', $item->get_rate_id('edit'));
wc_update_order_item_meta($item->get_id(), 'label', $item->get_label('edit'));
wc_update_order_item_meta($item->get_id(), 'compound', $item->get_compound('edit'));
wc_update_order_item_meta($item->get_id(), 'tax_amount', $item->get_tax_total('edit'));
wc_update_order_item_meta($item->get_id(), 'shipping_tax_amount', $item->get_shipping_tax_total('edit'));
}
示例6: save
/**
* Save properties specific to this order item.
* @return int Item ID
*/
public function save()
{
parent::save();
if ($this->get_id()) {
wc_update_order_item_meta($this->get_id(), 'discount_amount', $this->get_discount());
wc_update_order_item_meta($this->get_id(), 'discount_amount_tax', $this->get_discount_tax());
}
return $this->get_id();
}
示例7: save
/**
* Save properties specific to this order item.
* @return int Item ID
*/
public function save()
{
parent::save();
if ($this->get_id()) {
wc_update_order_item_meta($this->get_id(), 'method_id', $this->get_method_id());
wc_update_order_item_meta($this->get_id(), 'cost', $this->get_total());
wc_update_order_item_meta($this->get_id(), 'total_tax', $this->get_total_tax());
wc_update_order_item_meta($this->get_id(), 'taxes', $this->get_taxes());
}
return $this->get_id();
}
示例8: save_item_data
/**
* Saves an item's data to the database / item meta.
* Ran after both create and update, so $item->get_id() will be set.
*
* @since 2.7.0
* @param WC_Order_Item $item
*/
public function save_item_data(&$item)
{
wc_update_order_item_meta($item->get_id(), '_product_id', $item->get_product_id('edit'));
wc_update_order_item_meta($item->get_id(), '_variation_id', $item->get_variation_id('edit'));
wc_update_order_item_meta($item->get_id(), '_qty', $item->get_quantity('edit'));
wc_update_order_item_meta($item->get_id(), '_tax_class', $item->get_tax_class('edit'));
wc_update_order_item_meta($item->get_id(), '_line_subtotal', $item->get_subtotal('edit'));
wc_update_order_item_meta($item->get_id(), '_line_subtotal_tax', $item->get_subtotal_tax('edit'));
wc_update_order_item_meta($item->get_id(), '_line_total', $item->get_total('edit'));
wc_update_order_item_meta($item->get_id(), '_line_tax', $item->get_total_tax('edit'));
wc_update_order_item_meta($item->get_id(), '_line_tax_data', $item->get_taxes('edit'));
}
示例9: save
/**
* Save properties specific to this order item.
* @return int Item ID
*/
public function save()
{
parent::save();
if ($this->get_id()) {
wc_update_order_item_meta($this->get_id(), 'rate_id', $this->get_rate_id());
wc_update_order_item_meta($this->get_id(), 'label', $this->get_label());
wc_update_order_item_meta($this->get_id(), 'compound', $this->get_compound());
wc_update_order_item_meta($this->get_id(), 'tax_amount', $this->get_tax_total());
wc_update_order_item_meta($this->get_id(), 'shipping_tax_amount', $this->get_shipping_tax_total());
}
return $this->get_id();
}
示例10: update_post_metadata
/**
* Apply shipping tax, fix order_tax
* -
* - filter has already passed $this->data['shipping_tax'] test
* @param $null
* @param $order_id
* @param $meta_key
* @param $meta_value
* @param $prev_value
* @return null
*/
public function update_post_metadata($null, $order_id, $meta_key, $meta_value, $prev_value)
{
// we want last update to _order_shipping after $order->calculate_taxes()
// set flag true on first pass
if ($meta_key == '_order_shipping_tax') {
$this->flag = true;
}
if ($meta_key != '_order_shipping' || !$this->flag) {
return $null;
}
// update order meta
$shipping_tax_total = isset($this->data['shipping_tax']) ? $this->data['shipping_tax'] : 0;
update_post_meta($order_id, '_order_shipping_tax', wc_format_decimal($shipping_tax_total));
// check each shipping tax line
// if order item meta already exists, update the shipping_tax_amount
// if order item meta not present, add the new tax
// ... nasty :(
// first get an assoc array of $rate_id => $item_id
$tax_items = array();
$order_tax = 0;
$order = wc_get_order($order_id);
foreach ($order->get_tax_totals() as $code => $tax) {
$tax_items[$tax->rate_id] = $tax->id;
$order_tax += $tax->amount;
}
// fix total_tax calc
update_post_meta($order_id, '_order_tax', $order_tax);
// now loop through the shipping_lines
if (isset($shipping['shipping_lines'])) {
foreach ($this->data['shipping_lines'] as $shipping) {
if (isset($shipping['tax'])) {
foreach ($shipping['tax'] as $rate_id => $tax) {
if (isset($tax['total'])) {
if (array_key_exists($rate_id, $tax_items)) {
wc_update_order_item_meta($tax_items[$rate_id], 'shipping_tax_amount', wc_format_decimal($tax['total']));
} else {
$order->add_tax($rate_id, 0, $tax['total']);
}
}
}
}
}
}
return $null;
}
示例11: save
/**
* Save properties specific to this order item.
* @return int Item ID
*/
public function save()
{
parent::save();
if ($this->get_id()) {
wc_update_order_item_meta($this->get_id(), '_product_id', $this->get_product_id());
wc_update_order_item_meta($this->get_id(), '_variation_id', $this->get_variation_id());
wc_update_order_item_meta($this->get_id(), '_qty', $this->get_quantity());
wc_update_order_item_meta($this->get_id(), '_tax_class', $this->get_tax_class());
wc_update_order_item_meta($this->get_id(), '_line_subtotal', $this->get_subtotal());
wc_update_order_item_meta($this->get_id(), '_line_subtotal_tax', $this->get_subtotal_tax());
wc_update_order_item_meta($this->get_id(), '_line_total', $this->get_total());
wc_update_order_item_meta($this->get_id(), '_line_tax', $this->get_total_tax());
wc_update_order_item_meta($this->get_id(), '_line_tax_data', $this->get_taxes());
}
return $this->get_id();
}
示例12: save_item_data
/**
* Saves an item's data to the database / item meta.
* Ran after both create and update, so $item->get_id() will be set.
*
* @since 2.7.0
* @param WC_Order_Item $item
*/
public function save_item_data(&$item)
{
wc_update_order_item_meta($item->get_id(), 'discount_amount', $item->get_discount('edit'));
wc_update_order_item_meta($item->get_id(), 'discount_amount_tax', $item->get_discount_tax('edit'));
}
示例13: update_post_data
/**
* Perform data update
*
* @return JSON object with information about number of posts remaining, current update status
*/
public static function update_post_data()
{
global $wpdb;
// Number of posts to process at once
$posts_per_page = 10;
// Index of last processed post
$last_post = $_POST['last_post'];
// Page counters
$total_pages = $last_post == 0 ? 0 : $_POST['total_pages'];
$current_page = $last_post == 0 ? 1 : $_POST['current_page'];
// On first run, determine $total_count/$total_pages
if ($last_post == 0) {
$total_count = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_type = 'wootax_order'");
if ($total_count == 0) {
update_option('wootax_version', WT_VERSION);
self::dismiss_update_message();
die(json_encode(array('status' => 'done', 'message' => 'No more posts to update. Redirecting...', 'redirect' => get_admin_url('plugins.php'))));
}
$total_pages = ceil($total_count / $posts_per_page);
}
// Select posts from index $last_post to $posts_per_page for processing
$posts = $wpdb->get_results("SELECT p.ID AS WTID, pm.meta_value AS WCID FROM {$wpdb->posts} p LEFT JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID WHERE p.post_type = 'wootax_order' AND pm.meta_key = '_wootax_wc_order_id' ORDER BY p.ID ASC LIMIT {$last_post}, {$posts_per_page}");
if (count($posts) == 0) {
update_option('wootax_version', WT_VERSION);
self::dismiss_update_message();
self::remove_order_posts();
die(json_encode(array('status' => 'done', 'message' => 'No more posts to update. Redirecting...', 'redirect' => get_admin_url('plugins.php'))));
}
// Loop through posts and update
foreach ($posts as $post) {
$wt_order_id = $post->WTID;
$wc_order_id = $post->WCID;
// Transfer meta that doesn't need to be changed
$direct_meta_keys = array('tax_total', 'shipping_tax_total', 'captured', 'refunded', 'customer_id', 'tax_item_id', 'exemption_applied');
foreach ($direct_meta_keys as $key) {
update_post_meta($wc_order_id, '_wootax_' . $key, get_post_meta($wt_order_id, '_wootax_' . $key, true));
}
// WooTax order item meta and mapping array structure was changed drastically in 4.2; update accordingly
$lookup_data = get_post_meta($wt_order_id, '_wootax_lookup_data', true);
$cart_taxes = get_post_meta($wt_order_id, '_wootax_cart_taxes', true);
$new_mapping_array = array();
$new_tc_ids = array();
$identifiers = array();
if (is_array($lookup_data)) {
$wc_order = new WC_Order($wc_order_id);
$order_items = $wc_order->get_items();
$order_fees = $wc_order->get_fees();
foreach ($lookup_data as $location_key => $items) {
if (!isset($new_mapping_array[$location_key])) {
$new_mapping_array[$location_key] = array();
}
foreach ($items as $index => $item) {
if (!is_array($item)) {
continue;
}
$tax_amount = isset($cart_taxes[$location_key][$index]) ? $cart_taxes[$location_key][$index] : 0;
$item_ident = $item['ItemID'];
if ($item_ident == 99999) {
$shipping_item_id = -1;
// Shipping
if (version_compare(WOOCOMMERCE_VERSION, '2.2', '<')) {
$shipping_item_id = WT_SHIPPING_ITEM;
update_post_meta($wc_order_id, '_wootax_first_found', $location_key);
update_post_meta($wc_order_id, '_wootax_shipping_index', $index);
} else {
$shipping_methods = $wc_order->get_items('shipping');
foreach ($shipping_methods as $item_id => $method) {
if ($shipping_item_id == -1) {
$shipping_item_id = $item_id;
wc_update_order_item_meta($item_id, '_wootax_index', $index);
wc_update_order_item_meta($item_id, '_wootax_tax_amount', $tax_amount);
wc_update_order_item_meta($item_id, '_wootax_location_id', $location_key);
}
}
}
if ($shipping_item_id != -1) {
$new_mapping_array[$location_key][$item_ident] = $index;
$identifiers[WT_SHIPPING_ITEM] = $item_ident;
}
} else {
if (in_array(get_post_type($item_ident), array('product', 'product-variation'))) {
// Cart item
$cart_item_id = -1;
if (get_post_type($item_ident) == 'product') {
$product_id = $item_ident;
$variation_id = '';
} else {
if (get_post_type($item_ident) == 'product-variation') {
$variation_id = $item_ident;
$product_id = wp_get_post_parent_id($variation_id);
}
}
foreach ($order_items as $item_id => $item_data) {
if (!empty($item_data['variation_id']) && $item_data['variation_id'] == $variation_id || $item_data['product_id'] == $product_id) {
$cart_item_id = $item_id;
//.........这里部分代码省略.........
开发者ID:sergioblanco86,项目名称:git-gitlab.com-kinivo-kinivo.com,代码行数:101,代码来源:class-wc-wootax-upgrade.php
示例14: sa_restore_smart_coupon_amount
/**
* Function to Restore Smart Coupon Amount back, when an order which was created using this coupon, is refunded or cancelled,
*
* @param int $order_id
*/
public function sa_restore_smart_coupon_amount($order_id = 0)
{
if (empty($order_id)) {
return;
}
$order = $this->get_order($order_id);
$coupons = $order->get_items('coupon');
if (!empty($coupons)) {
foreach ($coupons as $item_id => $item) {
if (empty($item['name'])) {
continue;
}
$coupon = new WC_Coupon($item['name']);
if (empty($coupon->discount_type) || $coupon->discount_type != 'smart_coupon') {
continue;
}
$update = false;
$coupon_amount = $coupon->coupon_amount;
$usage_count = $coupon->usage_count;
if (!empty($item['discount_amount'])) {
$coupon_amount += $item['discount_amount'];
$usage_count -= 1;
if ($usage_count < 0) {
$usage_count = 0;
}
$update = true;
}
if ($update) {
update_post_meta($coupon->id, 'coupon_amount', $coupon_amount);
update_post_meta($coupon->id, 'usage_count', $usage_count);
wc_update_order_item_meta($item_id, 'discount_amount', 0);
}
}
}
}
示例15: ajax_add_order_item_meta
/**
* Triggered when adding an item in the backend.
*
* If deposits are forced, set all meta data.
*/
public function ajax_add_order_item_meta($item_id, $item)
{
if (WC_Deposits_Product_Manager::deposits_forced($item['product_id'])) {
$product = wc_get_product(absint($item['variation_id'] ? $item['variation_id'] : $item['product_id']));
woocommerce_add_order_item_meta($item_id, '_is_deposit', 'yes');
woocommerce_add_order_item_meta($item_id, '_deposit_full_amount', $item['line_total']);
woocommerce_add_order_item_meta($item_id, '_deposit_full_amount_ex_tax', $item['line_total']);
if ('plan' === WC_Deposits_Product_Manager::get_deposit_type($item['product_id'])) {
$plan_id = current(WC_Deposits_Plans_Manager::get_plan_ids_for_product($item['product_id']));
woocommerce_add_order_item_meta($item_id, '_payment_plan', $plan_id);
} else {
$plan_id = 0;
}
// Change line item costs
$deposit_amount = WC_Deposits_Product_Manager::get_deposit_amount($product, $plan_id, 'order', $item['line_total']);
wc_update_order_item_meta($item_id, '_line_total', $deposit_amount);
wc_update_order_item_meta($item_id, '_line_subtotal', $deposit_amount);
}
}