本文整理匯總了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;
}
}
}
}