Merge pull request #1281 from maxrice/master

coupons tweaks
This commit is contained in:
Mike Jolley 2012-07-22 05:53:24 -07:00
commit 6666af8de9
3 changed files with 18 additions and 3 deletions

View File

@ -148,6 +148,15 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
'show_if_checked' => 'option'
),
array(
'desc' => __( 'Enable coupon form on cart', 'woocommerce' ),
'id' => 'woocommerce_enable_coupon_form_on_cart',
'std' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
'show_if_checked' => 'yes'
),
array(
'desc' => __( 'Enable coupon form on checkout', 'woocommerce' ),
'id' => 'woocommerce_enable_coupon_form_on_checkout',

View File

@ -535,7 +535,13 @@ class WC_Checkout {
wp_set_object_terms( $order_id, 'pending', 'shop_order_status' );
// Discount code meta
if ($applied_coupons = $woocommerce->cart->get_applied_coupons()) update_post_meta($order_id, 'coupons', implode(', ', $applied_coupons));
if ( $applied_coupons = $woocommerce->cart->get_applied_coupons() ) {
update_post_meta( $order_id, 'coupons', implode(', ', $applied_coupons) );
$order = new WC_Order( $order_id );
$order->add_order_note( sprintf( __( 'Coupon Code Used: %s', 'woocommerce' ), implode(', ', $applied_coupons ) ) );
}
// Order is saved
do_action('woocommerce_checkout_order_processed', $order_id, $this->posted);

View File

@ -106,7 +106,7 @@ global $woocommerce;
<tr>
<td colspan="6" class="actions">
<?php if ( get_option( 'woocommerce_enable_coupons' ) == 'yes' ) { ?>
<?php if ( get_option( 'woocommerce_enable_coupons' ) == 'yes' && get_option( 'woocommerce_enable_coupon_form_on_cart' ) == 'yes') { ?>
<div class="coupon">
<label for="coupon_code"><?php _e('Coupon', 'woocommerce'); ?>:</label> <input name="coupon_code" class="input-text" id="coupon_code" value="" /> <input type="submit" class="button" name="apply_coupon" value="<?php _e('Apply Coupon', 'woocommerce'); ?>" />