本文整理汇总了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');
}
}
示例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');
}
示例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;
}
}
}
}
示例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;
}
}
}
}