Bug fixes
This commit is contained in:
parent
ec7135ebb4
commit
cc7e560a14
|
@ -553,8 +553,8 @@ function woocommerce_tax_row_label( $selected ) {
|
|||
if ($selected) foreach ($selected as $country => $value) :
|
||||
|
||||
$country = woocommerce_clean($country);
|
||||
|
||||
if (sizeof($value)>1) :
|
||||
|
||||
if (sizeof($value)>0 && $value[0]!=='*') :
|
||||
$states_count+=sizeof($value);
|
||||
endif;
|
||||
|
||||
|
|
|
@ -29,39 +29,39 @@ class woocommerce_coupon {
|
|||
$this->code = $code;
|
||||
|
||||
$coupon_data = apply_filters('woocommerce_get_shop_coupon_data', false, $code);
|
||||
|
||||
if ($coupon_data) :
|
||||
$this->id = $coupon_data['id'];
|
||||
$this->type = $coupon_data['type'];
|
||||
$this->amount = $coupon_data['amount'];
|
||||
$this->individual_use = $coupon_data['individual_use'];
|
||||
$this->product_ids = $coupon_data['product_ids'];
|
||||
$this->exclude_product_ids = $coupon_data['exclude_product_ids'];
|
||||
$this->usage_limit = $coupon_data['usage_limit'];
|
||||
$this->usage_count = $coupon_data['usage_count'];
|
||||
$this->expiry_date = $coupon_data['expiry_date'];
|
||||
$this->apply_before_tax = $coupon_data['apply_before_tax'];
|
||||
$this->free_shipping = $coupon_data['free_shipping'];
|
||||
return true;
|
||||
else:
|
||||
$coupon = get_page_by_title($this->code, 'OBJECT', 'shop_coupon');
|
||||
if ($coupon && $coupon->post_status == 'publish') :
|
||||
$this->id = $coupon->ID;
|
||||
$this->type = get_post_meta($coupon->ID, 'discount_type', true);
|
||||
$this->amount = get_post_meta($coupon->ID, 'coupon_amount', true);
|
||||
$this->individual_use = get_post_meta($coupon->ID, 'individual_use', true);
|
||||
$this->product_ids = array_filter(array_map('trim', explode(',', get_post_meta($coupon->ID, 'product_ids', true))));
|
||||
$this->exclude_product_ids = array_filter(array_map('trim', explode(',', get_post_meta($coupon->ID, 'exclude_product_ids', true))));
|
||||
$this->usage_limit = get_post_meta($coupon->ID, 'usage_limit', true);
|
||||
$this->usage_count = (int) get_post_meta($coupon->ID, 'usage_count', true);
|
||||
$this->expiry_date = ($expires = get_post_meta($coupon->ID, 'expiry_date', true)) ? strtotime($expires) : '';
|
||||
$this->apply_before_tax = get_post_meta($coupon->ID, 'apply_before_tax', true);
|
||||
$this->free_shipping = get_post_meta($coupon->ID, 'free_shipping', true);
|
||||
return true;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
return false;
|
||||
if ($coupon_data) :
|
||||
$this->id = $coupon_data['id'];
|
||||
$this->type = $coupon_data['type'];
|
||||
$this->amount = $coupon_data['amount'];
|
||||
$this->individual_use = $coupon_data['individual_use'];
|
||||
$this->product_ids = $coupon_data['product_ids'];
|
||||
$this->exclude_product_ids = $coupon_data['exclude_product_ids'];
|
||||
$this->usage_limit = $coupon_data['usage_limit'];
|
||||
$this->usage_count = $coupon_data['usage_count'];
|
||||
$this->expiry_date = $coupon_data['expiry_date'];
|
||||
$this->apply_before_tax = $coupon_data['apply_before_tax'];
|
||||
$this->free_shipping = $coupon_data['free_shipping'];
|
||||
return true;
|
||||
else:
|
||||
$coupon = get_page_by_title($this->code, 'OBJECT', 'shop_coupon');
|
||||
if ($coupon && $coupon->post_status == 'publish') :
|
||||
$this->id = $coupon->ID;
|
||||
$this->type = get_post_meta($coupon->ID, 'discount_type', true);
|
||||
$this->amount = get_post_meta($coupon->ID, 'coupon_amount', true);
|
||||
$this->individual_use = get_post_meta($coupon->ID, 'individual_use', true);
|
||||
$this->product_ids = array_filter(array_map('trim', explode(',', get_post_meta($coupon->ID, 'product_ids', true))));
|
||||
$this->exclude_product_ids = array_filter(array_map('trim', explode(',', get_post_meta($coupon->ID, 'exclude_product_ids', true))));
|
||||
$this->usage_limit = get_post_meta($coupon->ID, 'usage_limit', true);
|
||||
$this->usage_count = (int) get_post_meta($coupon->ID, 'usage_count', true);
|
||||
$this->expiry_date = ($expires = get_post_meta($coupon->ID, 'expiry_date', true)) ? strtotime($expires) : '';
|
||||
$this->apply_before_tax = get_post_meta($coupon->ID, 'apply_before_tax', true);
|
||||
$this->free_shipping = get_post_meta($coupon->ID, 'free_shipping', true);
|
||||
return true;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Check if coupon needs applying before tax **/
|
||||
|
|
|
@ -141,7 +141,7 @@ class free_shipping extends woocommerce_shipping_method {
|
|||
endif;
|
||||
|
||||
if ($this->requires_coupon=="yes") :
|
||||
|
||||
|
||||
if ($woocommerce->cart->applied_coupons) : foreach ($woocommerce->cart->applied_coupons as $code) :
|
||||
$coupon = &new woocommerce_coupon( $code );
|
||||
|
||||
|
|
|
@ -17,14 +17,8 @@ function get_woocommerce_cart( $atts ) {
|
|||
function woocommerce_cart( $atts ) {
|
||||
global $woocommerce;
|
||||
|
||||
// Process Discount Codes
|
||||
if (isset($_POST['apply_coupon']) && $_POST['apply_coupon'] && $woocommerce->verify_nonce('cart')) :
|
||||
|
||||
$coupon_code = stripslashes(trim($_POST['coupon_code']));
|
||||
$woocommerce->cart->add_discount($coupon_code);
|
||||
|
||||
// Remove Discount Codes
|
||||
elseif (isset($_GET['remove_discounts'])) :
|
||||
if (isset($_GET['remove_discounts'])) :
|
||||
|
||||
$woocommerce->cart->remove_coupons( $_GET['remove_discounts'] );
|
||||
$woocommerce->cart->calculate_totals();
|
||||
|
|
|
@ -23,7 +23,7 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
|
|||
<?php if ($woocommerce->cart->get_discounts_before_tax()) : ?>
|
||||
|
||||
<tr class="discount">
|
||||
<th><?php _e('Cart Discount', 'woothemes'); ?></th>
|
||||
<th><?php _e('Cart Discount', 'woothemes'); ?> <a href="<?php echo add_query_arg('remove_discounts', '1') ?>"><?php _e('[Remove]', 'woothemes'); ?></a></th>
|
||||
<td>-<?php echo $woocommerce->cart->get_discounts_before_tax(); ?></td>
|
||||
</tr>
|
||||
|
||||
|
@ -143,7 +143,7 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
|
|||
<?php if ($woocommerce->cart->get_discounts_after_tax()) : ?>
|
||||
|
||||
<tr class="discount">
|
||||
<th><?php _e('Order Discount', 'woothemes'); ?></th>
|
||||
<th><?php _e('Order Discount', 'woothemes'); ?> <a href="<?php echo add_query_arg('remove_discounts', '2') ?>"><?php _e('[Remove]', 'woothemes'); ?></a></th>
|
||||
<td>-<?php echo $woocommerce->cart->get_discounts_after_tax(); ?></td>
|
||||
</tr>
|
||||
|
||||
|
|
|
@ -419,7 +419,7 @@ function woocommerce_process_login() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Process the coupon form on the checkout
|
||||
* Process the coupon form on the checkout and cart
|
||||
**/
|
||||
function woocommerce_process_coupon_form() {
|
||||
global $woocommerce;
|
||||
|
@ -430,7 +430,7 @@ function woocommerce_process_coupon_form() {
|
|||
$woocommerce->cart->add_discount($coupon_code);
|
||||
|
||||
if ( wp_get_referer() ) :
|
||||
wp_safe_redirect( wp_get_referer() );
|
||||
wp_safe_redirect( remove_query_arg('remove_discounts', wp_get_referer()) );
|
||||
exit;
|
||||
endif;
|
||||
|
||||
|
|
Loading…
Reference in New Issue