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


PHP WC_Coupon::inc_usage_count方法代码示例

本文整理汇总了PHP中WC_Coupon::inc_usage_count方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Coupon::inc_usage_count方法的具体用法?PHP WC_Coupon::inc_usage_count怎么用?PHP WC_Coupon::inc_usage_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Coupon的用法示例。


在下文中一共展示了WC_Coupon::inc_usage_count方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: increase_coupon_usage_counts

 /**
  * Increase applied coupon counts
  */
 public function increase_coupon_usage_counts()
 {
     if ('yes' == get_post_meta($this->id, '_recorded_coupon_usage_counts', true)) {
         return;
     }
     if (sizeof($this->get_used_coupons()) > 0) {
         foreach ($this->get_used_coupons() as $code) {
             if (!$code) {
                 continue;
             }
             $coupon = new WC_Coupon($code);
             $used_by = $this->get_user_id();
             if (!$used_by) {
                 $used_by = $this->billing_email;
             }
             $coupon->inc_usage_count($used_by);
         }
         update_post_meta($this->id, '_recorded_coupon_usage_counts', 'yes');
     }
 }
开发者ID:danisdead,项目名称:gastrointernacional,代码行数:23,代码来源:abstract-wc-order.php

示例2: sc_subscriptions_renewal_order_items

 /**
  * function to modify order_items of renewal order
  *
  * @param array $order_items
  * @param int $original_order_id
  * @param int $renewal_order_id
  * @param int $product_id
  * @param string $new_order_role
  * @return array $order_items
  */
 public function sc_subscriptions_renewal_order_items($order_items = null, $original_order_id = 0, $renewal_order_id = 0, $product_id = 0, $new_order_role = null)
 {
     $pay_from_credit_of_original_order = get_option('pay_from_smart_coupon_of_original_order', 'yes');
     if ($pay_from_credit_of_original_order != 'yes') {
         return;
     }
     if ($new_order_role != 'child') {
         return;
     }
     if (empty($renewal_order_id) || empty($original_order_id)) {
         return;
     }
     $original_order = $this->get_order($original_order_id);
     $renewal_order = $this->get_order($renewal_order_id);
     $coupon_used_in_original_order = $original_order->get_used_coupons();
     $coupon_used_in_renewal_order = $renewal_order->get_used_coupons();
     if (sizeof($coupon_used_in_original_order) > 0) {
         $smart_coupons_contribution = array();
         foreach ($coupon_used_in_original_order as $coupon_code) {
             $coupon = new WC_Coupon($coupon_code);
             if (!empty($coupon->discount_type) && $coupon->discount_type == 'smart_coupon' && !empty($coupon->amount) && !in_array($coupon_code, $coupon_used_in_renewal_order, true)) {
                 $renewal_order_total = $renewal_order->get_total();
                 $discount = min($renewal_order_total, $coupon->amount);
                 if ($discount > 0) {
                     $new_order_total = $renewal_order_total - $discount;
                     update_post_meta($renewal_order_id, '_order_total', $new_order_total);
                     update_post_meta($renewal_order_id, '_order_discount', $discount);
                     if ($new_order_total <= floatval(0)) {
                         update_post_meta($renewal_order_id, '_renewal_paid_by_smart_coupon', 'yes');
                     }
                     $renewal_order->add_coupon($coupon_code, $discount);
                     $smart_coupons_contribution[$coupon_code] = $discount;
                     $used_by = $renewal_order->get_user_id();
                     if (!$used_by) {
                         $used_by = $renewal_order->billing_email;
                     }
                     $coupon->inc_usage_count($used_by);
                 }
             }
         }
         if (!empty($smart_coupons_contribution)) {
             update_post_meta($renewal_order_id, 'smart_coupons_contribution', $smart_coupons_contribution);
         }
     }
     return $order_items;
 }
开发者ID:NerdyDillinger,项目名称:ovrride,代码行数:56,代码来源:woocommerce-smart-coupons.php

示例3: wc_update_coupon_usage_counts

/**
 * Update used coupon amount for each coupon within an order.
 *
 * @since 2.7.0
 * @param int $order_id
 */
function wc_update_coupon_usage_counts($order_id)
{
    if (!($order = wc_get_order($order_id))) {
        return;
    }
    $has_recorded = $order->get_data_store()->get_recorded_coupon_usage_counts($order);
    if ($order->has_status('cancelled') && $has_recorded) {
        $action = 'reduce';
        $order->get_data_store()->set_recorded_coupon_usage_counts($order, false);
    } elseif (!$order->has_status('cancelled') && !$has_recorded) {
        $action = 'increase';
        $order->get_data_store()->set_recorded_coupon_usage_counts($order, true);
    } else {
        return;
    }
    if (sizeof($order->get_used_coupons()) > 0) {
        foreach ($order->get_used_coupons() as $code) {
            if (!$code) {
                continue;
            }
            $coupon = new WC_Coupon($code);
            if (!($used_by = $order->get_user_id())) {
                $used_by = $order->get_billing_email();
            }
            switch ($action) {
                case 'reduce':
                    $coupon->dcr_usage_count($used_by);
                    break;
                case 'increase':
                    $coupon->inc_usage_count($used_by);
                    break;
            }
        }
    }
}
开发者ID:woocommerce,项目名称:woocommerce,代码行数:41,代码来源:wc-order-functions.php

示例4: increase_coupon_usage_counts

 /**
  * Increase applied coupon counts
  *
  * @access public
  * @return void
  */
 public function increase_coupon_usage_counts()
 {
     global $woocommerce;
     if (get_post_meta($this->id, '_recorded_coupon_usage_counts', true) == 'yes') {
         return;
     }
     if (sizeof($this->get_used_coupons()) > 0) {
         foreach ($this->get_used_coupons() as $code) {
             if (!$code) {
                 continue;
             }
             $coupon = new WC_Coupon($code);
             $coupon->inc_usage_count();
         }
     }
     update_post_meta($this->id, '_recorded_coupon_usage_counts', 'yes');
 }
开发者ID:googlecode-mirror,项目名称:wpmu-demo,代码行数:23,代码来源:class-wc-order.php

示例5: woocommerce_increase_coupon_counts

/**
 * Increase coupon usage count
 */
function woocommerce_increase_coupon_counts()
{
    global $woocommerce;
    if ($applied_coupons = $woocommerce->cart->get_applied_coupons()) {
        foreach ($applied_coupons as $code) {
            $coupon = new WC_Coupon($code);
            $coupon->inc_usage_count();
        }
    }
}
开发者ID:rosslavery,项目名称:woocommerce,代码行数:13,代码来源:woocommerce-functions.php

示例6: wc_update_coupon_usage_counts

/**
 * Update used coupon amount for each coupon within an order.
 *
 * @since 2.7.0
 * @param int $order_id
 */
function wc_update_coupon_usage_counts($order_id)
{
    $order = wc_get_order($order_id);
    $has_recorded = get_post_meta($order_id, '_recorded_coupon_usage_counts', true);
    if (!$order) {
        return;
    }
    if ($order->has_status('cancelled') && 'yes' === $has_recorded) {
        $action = 'reduce';
        delete_post_meta($order_id, '_recorded_coupon_usage_counts');
    } elseif (!$order->has_status('cancelled') && 'yes' !== $has_recorded) {
        $action = 'increase';
        update_post_meta($order_id, '_recorded_coupon_usage_counts', 'yes');
    } else {
        return;
    }
    if (sizeof($order->get_used_coupons()) > 0) {
        foreach ($order->get_used_coupons() as $code) {
            if (!$code) {
                continue;
            }
            $coupon = new WC_Coupon($code);
            if (!($used_by = $order->get_user_id())) {
                $used_by = $order->get_billing_email();
            }
            switch ($action) {
                case 'reduce':
                    $coupon->dcr_usage_count($used_by);
                    break;
                case 'increase':
                    $coupon->inc_usage_count($used_by);
                    break;
            }
        }
    }
}
开发者ID:Korkey128k,项目名称:woocommerce,代码行数:42,代码来源:wc-order-functions.php


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