Created
July 13, 2014 07:13
-
-
Save furahaclothing/71591dcffed7e498e162 to your computer and use it in GitHub Desktop.
welcart クーポン機能 *エラー表示検証する*
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//welcart クーポンコード | |
add_filter('usces_order_discount', 'coupon_order_discount', 10, 2); | |
function coupon_order_discount($discount, $cart){ | |
global $usces; | |
$entry = $usces->cart->get_entry(); | |
$total_items_price = $usces->get_total_price(); | |
if($entry['custom_order']['coupon'] == 'クーポンコード'){ | |
$discount = ceil($total_items_price * 0.1 * -1); | |
} | |
return $discount; | |
} | |
//クーポン書き換え | |
add_filter('usces_confirm_discount_label', 'coupon_confirm_discount_label', 10, 1); | |
function coupon_confirm_discount_label(){ | |
global $usces; | |
$entry = $usces->cart->get_entry(); | |
$order_id = $_POST['order_id']; | |
if($entry['custom_order']['coupon'] == 'furaha10' || $usces->get_order_meta_value('csod_coupon', $order_id) == true){ | |
$text = "クーポン割引"; | |
} else { | |
$text = __('Campaign disnount', 'usces'); | |
} | |
return $text; | |
} | |
//クーポンコードがエラーの時の表示 | |
add_action('usces_filter_confirm_page_header', 'coupon_confirm_page_header', 10, 1); | |
function coupon_confirm_page_header(){ | |
global $usces; | |
$entry = $usces->cart->get_entry(); | |
if($entry['custom_order']['coupon'] == true && $entry['custom_order']['coupon'] != "クーポンコード"){ | |
$html .= '<span class="coupon-error">クーポンコードが違います。</span>'; | |
} | |
return do_shortcode( stripslashes(nl2br($html)) ); | |
} | |
//クーポン入力フィールドの横にテキスト | |
add_filter('usces_filter_custom_field_input_value', 'coupon_custom_field_input', 10, 3); | |
function coupon_custom_field_input($html, $key, $entry){ | |
if($key == 'coupon'){ | |
$html .= '<span class="coupon-text"> クーポンコードお持ちの方はご記入下さい。</span>'; | |
} | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment