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


PHP WC_Coupon::dcr_usage_count方法代码示例

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


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

示例1: decrease_coupon_usage_counts

 /**
  * Decrease applied coupon counts
  */
 public function decrease_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->dcr_usage_count($used_by);
         }
         delete_post_meta($this->id, '_recorded_coupon_usage_counts');
     }
 }
开发者ID:danisdead,项目名称:gastrointernacional,代码行数:23,代码来源:abstract-wc-order.php

示例2: decrease_coupon_usage_counts

 /**
  * Decrease applied coupon counts
  *
  * @access public
  * @return void
  */
 public function decrease_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->dcr_usage_count();
         }
     }
     delete_post_meta($this->id, '_recorded_coupon_usage_counts');
 }
开发者ID:googlecode-mirror,项目名称:wpmu-demo,代码行数:23,代码来源:class-wc-order.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: 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::dcr_usage_count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。