Version Description
- RENAME: Renamed plugin from "WooCommerce auto added coupons" to "WooCommerce Extended Coupon Features"
- FEATURE: Restrict coupons by payment method
- FEATURE: Restrict coupons by shipping method
- FEATURE: Use AND-operator for the selected products (default is OR)
- FIX: Validate email restrictions for auto coupons
- Norwegian translation added (Thanks to Anders Zorensen)
Download this release
Release Info
Developer | josk79 |
Plugin | WooCommerce Extended Coupon Features |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.5 to 2.0.0
- assets/screenshot-1.png +0 -0
- includes/wjecf-autocoupon.php +371 -0
- includes/wjecf-coupon-extensions.php +197 -0
- languages/woocommerce-jos-autocoupon-de_DE.mo +0 -0
- languages/woocommerce-jos-autocoupon-de_DE.po +43 -25
- languages/woocommerce-jos-autocoupon-es_ES.mo +0 -0
- languages/woocommerce-jos-autocoupon-es_ES.po +77 -26
- languages/woocommerce-jos-autocoupon-nb_NO.mo +0 -0
- languages/woocommerce-jos-autocoupon-nb_NO.po +98 -0
- languages/woocommerce-jos-autocoupon-nl_NL.mo +0 -0
- languages/woocommerce-jos-autocoupon-nl_NL.po +72 -30
- languages/woocommerce-jos-autocoupon.pot +42 -24
- readme.txt +52 -15
- woocommerce-jos-autocoupon.php +56 -267
assets/screenshot-1.png
CHANGED
Binary file
|
includes/wjecf-autocoupon.php
ADDED
@@ -0,0 +1,371 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WC_Jos_AutoCoupon_Controller{
|
4 |
+
|
5 |
+
private $_autocoupon_codes = null;
|
6 |
+
|
7 |
+
private $_user_emails = null;
|
8 |
+
|
9 |
+
private $_check_already_performed = false;
|
10 |
+
|
11 |
+
public function __construct() {
|
12 |
+
add_action('init', array( &$this, 'controller_init' ));
|
13 |
+
}
|
14 |
+
|
15 |
+
public function controller_init() {
|
16 |
+
if ( ! class_exists('WC_Coupon') ) {
|
17 |
+
return;
|
18 |
+
}
|
19 |
+
|
20 |
+
$this->log( $_SERVER['REQUEST_URI'] );
|
21 |
+
|
22 |
+
//Admin hooks
|
23 |
+
add_action( 'woocommerce_coupon_options_usage_restriction', array( $this, 'coupon_options' ), 10, 0 );
|
24 |
+
add_action( 'woocommerce_process_shop_coupon_meta', array( $this, 'process_shop_coupon_meta' ), 10, 2 );
|
25 |
+
|
26 |
+
//Frontend hooks
|
27 |
+
add_action( 'woocommerce_check_cart_items', array( &$this, 'update_matched_autocoupons' ) , 0 ); //Remove coupon before WC does it and shows a message
|
28 |
+
add_action( 'woocommerce_before_cart_totals', array( &$this, 'update_matched_autocoupons' ) ); //When cart is updated after changing shipping method
|
29 |
+
add_action( 'woocommerce_review_order_before_cart_contents', array( &$this, 'update_matched_autocoupons' ) ); //When cart is updated after changing shipping or payment method
|
30 |
+
|
31 |
+
add_filter('woocommerce_cart_totals_coupon_label', array( &$this, 'coupon_label' ), 10, 2 );
|
32 |
+
add_filter('woocommerce_cart_totals_coupon_html', array( &$this, 'coupon_html' ), 10, 2 );
|
33 |
+
|
34 |
+
//Last check for coupons with restricted_emails
|
35 |
+
//DONT USE: Breaks cart preview update //add_action( 'woocommerce_checkout_update_order_review', array( $this, 'checkout_update_order_review' ), 10 ); // AJAX One page checkout //
|
36 |
+
add_action( 'woocommerce_after_checkout_validation', array( $this, 'after_checkout_validation' ), 0 ); // After checkout / before payment
|
37 |
+
|
38 |
+
add_action( 'wp_loaded', array( &$this, 'coupon_by_url' )); //Coupon through url
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
/* ADMIN HOOKS */
|
43 |
+
|
44 |
+
public function coupon_options() {
|
45 |
+
|
46 |
+
// Auto coupon checkbox
|
47 |
+
woocommerce_wp_checkbox( array(
|
48 |
+
'id' => 'woocommerce-jos-autocoupon',
|
49 |
+
'label' => __( 'Auto coupon', 'woocommerce-jos-autocoupon' ),
|
50 |
+
'description' => __( "Automatically add the coupon to the cart if the restrictions are met. Please enter a description when you check this box, the description will be shown in the customers cart if the coupon is applied.", 'woocommerce-jos-autocoupon' )
|
51 |
+
) );
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
public function process_shop_coupon_meta( $post_id, $post ) {
|
56 |
+
$autocoupon = isset( $_POST['woocommerce-jos-autocoupon'] ) ? 'yes' : 'no';
|
57 |
+
update_post_meta( $post_id, 'woocommerce-jos-autocoupon', $autocoupon );
|
58 |
+
}
|
59 |
+
|
60 |
+
/* FRONTEND HOOKS */
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Add coupon through url
|
64 |
+
*/
|
65 |
+
public function coupon_by_url() {
|
66 |
+
if (isset($_GET['apply_coupon'])) {
|
67 |
+
$split = explode( ",", $_GET['apply_coupon'] );
|
68 |
+
|
69 |
+
global $woocommerce;
|
70 |
+
foreach ( $split as $coupon_code ) {
|
71 |
+
$woocommerce->cart->add_discount( $coupon_code );
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Overwrite the html created by wc_cart_totals_coupon_label() so a descriptive text will be shown for the discount.
|
78 |
+
* @param string $originaltext The default text created by wc_cart_totals_coupon_label()
|
79 |
+
* @param WC_Coupon $coupon The coupon data
|
80 |
+
* @return string The overwritten text
|
81 |
+
*/
|
82 |
+
function coupon_label( $originaltext, $coupon ) {
|
83 |
+
|
84 |
+
if ( $this->is_auto_coupon($coupon) ) {
|
85 |
+
|
86 |
+
return $this->coupon_excerpt($coupon); //__($this->autocoupons[$coupon->code], 'woocommerce-jos-autocoupon');
|
87 |
+
} else {
|
88 |
+
return $originaltext;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Overwrite the html created by wc_cart_totals_coupon_html(). This function is required to remove the "Remove" link.
|
94 |
+
* @param string $originaltext The html created by wc_cart_totals_coupon_html()
|
95 |
+
* @param WC_Coupon $coupon The coupon data
|
96 |
+
* @return string The overwritten html
|
97 |
+
*/
|
98 |
+
function coupon_html( $originaltext, $coupon ) {
|
99 |
+
if ( $this->is_auto_coupon($coupon) ) {
|
100 |
+
$value = array();
|
101 |
+
|
102 |
+
if ( $amount = WC()->cart->get_coupon_discount_amount( $coupon->code, WC()->cart->display_cart_ex_tax ) ) {
|
103 |
+
$discount_html = '-' . wc_price( $amount );
|
104 |
+
} else {
|
105 |
+
$discount_html = '';
|
106 |
+
}
|
107 |
+
|
108 |
+
$value[] = apply_filters( 'woocommerce_coupon_discount_amount_html', $discount_html, $coupon );
|
109 |
+
|
110 |
+
if ( $coupon->enable_free_shipping() ) {
|
111 |
+
$value[] = __( 'Free shipping coupon', 'woocommerce' );
|
112 |
+
}
|
113 |
+
|
114 |
+
return implode(', ', array_filter($value)); //Remove empty array elements
|
115 |
+
} else {
|
116 |
+
return $originaltext;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Apply matched autocoupons and remove unmatched autocoupons.
|
122 |
+
* @return void
|
123 |
+
*/
|
124 |
+
function update_matched_autocoupons() {
|
125 |
+
$this->log ( 'update_matched_autocoupons' );
|
126 |
+
if ( $this->_check_already_performed ) return;
|
127 |
+
|
128 |
+
global $woocommerce;
|
129 |
+
$this->remove_unmatched_autocoupons();
|
130 |
+
foreach ( $this->get_all_auto_coupons() as $coupon_code ) {
|
131 |
+
if ( ! $woocommerce->cart->has_discount( $coupon_code ) ) {
|
132 |
+
$coupon = new WC_Coupon($coupon_code);
|
133 |
+
if ( $this->coupon_can_be_applied($coupon) ) {
|
134 |
+
$this->log( sprintf( "Applying %s", $coupon_code ) );
|
135 |
+
$woocommerce->cart->add_discount( $coupon_code );
|
136 |
+
$this->overwrite_success_message( $coupon );
|
137 |
+
} else {
|
138 |
+
$this->log( sprintf( "Not applicable: %s", $coupon_code ) );
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
$this->_check_already_performed = true;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Test whether the coupon is valid and has a discount > 0
|
147 |
+
* @return bool
|
148 |
+
*/
|
149 |
+
function coupon_can_be_applied($coupon) {
|
150 |
+
global $woocommerce;
|
151 |
+
|
152 |
+
//Test validity
|
153 |
+
if ( ! $coupon->is_valid() ) {
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
//Test individual use
|
157 |
+
if ( $coupon->individual_use == 'yes' && count( $woocommerce->cart->applied_coupons ) != 0 ) {
|
158 |
+
return false;
|
159 |
+
}
|
160 |
+
|
161 |
+
//Test restricted emails
|
162 |
+
//See WooCommerce: class-wc-cart.php function check_customer_coupons
|
163 |
+
if ( is_array( $coupon->customer_email ) && sizeof( $coupon->customer_email ) > 0 ) {
|
164 |
+
$user_emails = array_map( 'sanitize_email', array_map( 'strtolower', $this->get_user_emails() ) );
|
165 |
+
$coupon_emails = array_map( 'sanitize_email', array_map( 'strtolower', $coupon->customer_email ) );
|
166 |
+
|
167 |
+
if ( 0 == sizeof( array_intersect( $user_emails, $coupon_emails ) ) ) {
|
168 |
+
return false;
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
//===========================================
|
173 |
+
//Can be applied. Now test if it has a value
|
174 |
+
|
175 |
+
if ( $coupon->enable_free_shipping() ) {
|
176 |
+
return true;
|
177 |
+
}
|
178 |
+
//Test whether discount > 0
|
179 |
+
//See WooCommerce: class-wc-cart.php function get_discounted_price
|
180 |
+
foreach ( $woocommerce->cart->get_cart() as $cart_item) {
|
181 |
+
if ( $coupon->is_valid_for_cart() || $coupon->is_valid_for_product( $cart_item['data'], $cart_item ) ) {
|
182 |
+
if ( $coupon->get_discount_amount( $cart_item['data']->price, $cart_item ) > 0 ) {
|
183 |
+
return true;
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
return false;
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Remove unmatched autocoupons. No message will be shown.
|
196 |
+
* NOTE: This function must be called before WooCommerce removes the coupon, to inhibit WooCommerces "coupon not valid"-message!
|
197 |
+
* @return void
|
198 |
+
*/
|
199 |
+
function remove_unmatched_autocoupons() {
|
200 |
+
global $woocommerce;
|
201 |
+
|
202 |
+
foreach ( $this->get_all_auto_coupons() as $coupon_code ) {
|
203 |
+
if ( $woocommerce->cart->has_discount( $coupon_code ) ) {
|
204 |
+
$coupon = new WC_Coupon($coupon_code);
|
205 |
+
if ( ! $this->coupon_can_be_applied($coupon) ) {
|
206 |
+
$this->log( sprintf( "Removing %s", $coupon_code ) );
|
207 |
+
WC()->cart->remove_coupon( $coupon_code );
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Overwrite the default "Coupon added" notice with a more descriptive message.
|
215 |
+
* @param WC_Coupon $coupon The coupon data
|
216 |
+
* @return void
|
217 |
+
*/
|
218 |
+
private function overwrite_success_message( $coupon ) {
|
219 |
+
$succss_msg = $coupon->get_coupon_message( WC_Coupon::WC_COUPON_SUCCESS );
|
220 |
+
|
221 |
+
$new_succss_msg = sprintf(
|
222 |
+
__("Discount applied: %s", 'woocommerce-jos-autocoupon'),
|
223 |
+
__($this->coupon_excerpt($coupon), 'woocommerce-jos-autocoupon')
|
224 |
+
);
|
225 |
+
|
226 |
+
//Compatibility woocommerce-2-1-notice-api
|
227 |
+
if ( function_exists('wc_get_notices') ) {
|
228 |
+
$all_notices = wc_get_notices();
|
229 |
+
$messages = $all_notices['success'];
|
230 |
+
} else {
|
231 |
+
$messages = $woocommerce->messages;
|
232 |
+
}
|
233 |
+
|
234 |
+
$sizeof_messages = sizeof($messages);
|
235 |
+
for( $y=0; $y < $sizeof_messages; $y++ ) {
|
236 |
+
if ( $messages[$y] == $succss_msg ) {
|
237 |
+
if ( isset($all_notices) ) {
|
238 |
+
if (defined('DOING_AJAX') && DOING_AJAX) {
|
239 |
+
unset ( $all_notices['success'][$y] );
|
240 |
+
} else {
|
241 |
+
$all_notices['success'][$y] = $new_succss_msg;
|
242 |
+
}
|
243 |
+
|
244 |
+
WC()->session->set( 'wc_notices', $all_notices );
|
245 |
+
} else {
|
246 |
+
if (defined('DOING_AJAX') && DOING_AJAX) {
|
247 |
+
unset ( $messages[$y] );
|
248 |
+
} else {
|
249 |
+
$messages[$y] = $new_succss_msg;
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
break;
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Check wether the coupon is an "Auto coupon".
|
260 |
+
* @param WC_Coupon $coupon The coupon data
|
261 |
+
* @return bool true if it is an "Auto coupon"
|
262 |
+
*/
|
263 |
+
private function is_auto_coupon($coupon) {
|
264 |
+
return get_post_meta( $coupon->id, 'woocommerce-jos-autocoupon', true ) == 'yes';
|
265 |
+
}
|
266 |
+
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Get the coupon excerpt (description)
|
270 |
+
* @param WC_Coupon $coupon The coupon data
|
271 |
+
* @return string The excerpt (translated)
|
272 |
+
*/
|
273 |
+
private function coupon_excerpt($coupon) {
|
274 |
+
$my_post = get_post($coupon->id);
|
275 |
+
return __($my_post->post_excerpt, 'woocommerce-jos-autocoupon');
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Get a list of the users' known email addresses
|
280 |
+
*
|
281 |
+
*/
|
282 |
+
private function get_user_emails() {
|
283 |
+
if ( ! is_array($this->_user_emails) ) {
|
284 |
+
$this->_user_emails = array();
|
285 |
+
//Email of the logged in user
|
286 |
+
if ( is_user_logged_in() ) {
|
287 |
+
$current_user = wp_get_current_user();
|
288 |
+
$this->_user_emails[] = $current_user->user_email;
|
289 |
+
}
|
290 |
+
}
|
291 |
+
$this->log( "User emails: ", join( ",", $this->_user_emails ) );
|
292 |
+
return $this->_user_emails;
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Append a single or an array of email addresses.
|
297 |
+
* @param array|string $append_emails The email address(es) to be added
|
298 |
+
* @return void
|
299 |
+
*/
|
300 |
+
private function append_user_emails($append_emails) {
|
301 |
+
//$append_emails must be an array
|
302 |
+
if ( ! is_array( $append_emails ) ) {
|
303 |
+
$append_emails = array( $append_emails );
|
304 |
+
}
|
305 |
+
|
306 |
+
$this->_user_emails = array_merge( $this->get_user_emails(), $append_emails );
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* After checkout validation
|
311 |
+
* Get billing email for coupon with restricted_emails
|
312 |
+
* Append matching coupons with restricted emails
|
313 |
+
* @param $posted array Billing data
|
314 |
+
* @return void
|
315 |
+
*/
|
316 |
+
public function after_checkout_validation( $posted ) {
|
317 |
+
$this->log ( 'update_matched_autocoupons' );
|
318 |
+
// $this->log ( sprintf( "After checkout: %s", print_r ( $posted, true ) ) );
|
319 |
+
$this->get_user_emails();
|
320 |
+
if ( isset ( $posted['billing_email'] ) ) {
|
321 |
+
$this->append_user_emails( $posted['billing_email'] );
|
322 |
+
}
|
323 |
+
|
324 |
+
$this->update_matched_autocoupons();
|
325 |
+
}
|
326 |
+
|
327 |
+
//Same as after_checkout_validation, only post_data is a query=string&like=this that must be converted to an array
|
328 |
+
public function checkout_update_order_review( $post_data ) {
|
329 |
+
$posted = array();
|
330 |
+
parse_str( $post_data, $posted );
|
331 |
+
$this->after_checkout_validation( $posted );
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Get a list of all auto coupon codes
|
336 |
+
* @return array All auto coupon codes
|
337 |
+
*/
|
338 |
+
private function get_all_auto_coupons() {
|
339 |
+
|
340 |
+
if ( !is_array($this->_autocoupon_codes) ) {
|
341 |
+
$this->_autocoupon_codes = array();
|
342 |
+
|
343 |
+
$query_args = array(
|
344 |
+
'posts_per_page' => -1,
|
345 |
+
'post_type' => 'shop_coupon',
|
346 |
+
'post_status' => 'publish',
|
347 |
+
'orderby' => 'title',
|
348 |
+
'meta_query' => array(
|
349 |
+
array(
|
350 |
+
'key' => 'woocommerce-jos-autocoupon',
|
351 |
+
'value' => 'yes',
|
352 |
+
'compare' => '=',
|
353 |
+
),
|
354 |
+
)
|
355 |
+
);
|
356 |
+
|
357 |
+
$query = new WP_Query($query_args);
|
358 |
+
foreach ($query->posts as $post) {
|
359 |
+
$coupon = new WC_Coupon($post->post_title);
|
360 |
+
if ( $this->is_auto_coupon($coupon) ) {
|
361 |
+
$this->_autocoupon_codes[] = $post->post_title;
|
362 |
+
}
|
363 |
+
}
|
364 |
+
}
|
365 |
+
return $this->_autocoupon_codes;
|
366 |
+
}
|
367 |
+
|
368 |
+
private function log ( $string ) {
|
369 |
+
// file_put_contents ( "/lamp/www/logfile.log", current_filter() . ": " . $string . "\n" , FILE_APPEND );
|
370 |
+
}
|
371 |
+
}
|
includes/wjecf-coupon-extensions.php
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
defined('ABSPATH') or die();
|
5 |
+
|
6 |
+
class WC_Jos_Extended_Coupon_Features_Controller {
|
7 |
+
|
8 |
+
public function __construct() {
|
9 |
+
add_action('init', array( &$this, 'controller_init' ));
|
10 |
+
}
|
11 |
+
|
12 |
+
public function controller_init() {
|
13 |
+
if ( ! class_exists('WC_Coupon') ) {
|
14 |
+
return;
|
15 |
+
}
|
16 |
+
|
17 |
+
//Admin hooks
|
18 |
+
add_action( 'woocommerce_coupon_options_usage_restriction', array( $this, 'coupon_options' ), 10, 0 );
|
19 |
+
add_action( 'woocommerce_process_shop_coupon_meta', array( $this, 'process_shop_coupon_meta' ), 10, 2 );
|
20 |
+
|
21 |
+
//Frontend hooks
|
22 |
+
add_filter('woocommerce_coupon_is_valid', array( &$this, 'coupon_is_valid' ), 10, 2 );
|
23 |
+
}
|
24 |
+
|
25 |
+
/* ADMIN HOOKS */
|
26 |
+
|
27 |
+
public function coupon_options() {
|
28 |
+
global $thepostid, $post;
|
29 |
+
$thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
|
30 |
+
|
31 |
+
//See WooCommerce class-wc-meta-box-coupon-data.php function ouput
|
32 |
+
|
33 |
+
//Title
|
34 |
+
echo "<h3 style='display:inline'>" . __( 'Extended Coupon Features', 'woocommerce-jos-autocoupon' ) . "</h3>\n";
|
35 |
+
printf( '<a href="%s" title="Support the development" target="_blank">', $this->get_donate_url() );
|
36 |
+
_e('Donate to the developer', 'woocommerce-jos-autocoupon' );
|
37 |
+
echo "</a>\n";
|
38 |
+
|
39 |
+
// AND in stead of OR the products
|
40 |
+
woocommerce_wp_checkbox( array(
|
41 |
+
'id' => '_wjecf_products_and',
|
42 |
+
'label' => __( 'AND Products (not OR)', 'woocommerce-jos-autocoupon' ),
|
43 |
+
'description' => __( 'Check this box if ALL of the products (see above) must be in the cart to use this coupon (in stead of only one of the products).', 'woocommerce-jos-autocoupon' )
|
44 |
+
) );
|
45 |
+
|
46 |
+
|
47 |
+
//Trick to show AND or OR next to the product_ids field
|
48 |
+
$label_and = __( '(AND)', 'woocommerce-jos-autocoupon' );
|
49 |
+
$label_or = __( '(OR)', 'woocommerce-jos-autocoupon' );
|
50 |
+
$label = get_post_meta( $thepostid, '_wjecf_products_and', true ) == 'yes' ? $label_and : $label_or;
|
51 |
+
?>
|
52 |
+
<script type="text/javascript">
|
53 |
+
//Update AND or OR in product_ids label when checkbox value changes
|
54 |
+
jQuery("#_wjecf_products_and").click(
|
55 |
+
function() {
|
56 |
+
jQuery("#wjecf_products_and_label").text(
|
57 |
+
jQuery("#_wjecf_products_and").attr('checked') ? "<?php echo $label_and; ?>" : "<?php echo $label_or; ?>"
|
58 |
+
);
|
59 |
+
} );
|
60 |
+
//Append AND/OR to the product_ids label
|
61 |
+
jQuery(".form-field:has('[name=\"product_ids\"]') label").append( ' <strong><span id="wjecf_products_and_label"><?php echo $label; ?></span></strong>' );
|
62 |
+
</script>
|
63 |
+
<?php //End of the AND/OR trick
|
64 |
+
|
65 |
+
|
66 |
+
// Shipping methods
|
67 |
+
?>
|
68 |
+
<p class="form-field"><label for="wjecf_shipping_methods"><?php _e( 'Shipping methods', 'woocommerce-jos-autocoupon' ); ?></label>
|
69 |
+
<select id="wjecf_shipping_methods" name="wjecf_shipping_methods[]" style="width: 50%;" class="wc-enhanced-select" multiple="multiple" data-placeholder="<?php _e( 'Any shipping method', 'woocommerce-jos-autocoupon' ); ?>">
|
70 |
+
<?php
|
71 |
+
$shipping_method_ids = (array) get_post_meta( $thepostid, '_wjecf_shipping_methods', true );
|
72 |
+
$shipping_methods = WC()->shipping->load_shipping_methods();
|
73 |
+
|
74 |
+
if ( $shipping_methods ) foreach ( $shipping_methods as $shipping_method ) {
|
75 |
+
echo '<option value="' . esc_attr( $shipping_method->id ) . '"' . selected( in_array( $shipping_method->id, $shipping_method_ids ), true, false ) . '>' . esc_html( $shipping_method->method_title ) . '</option>';
|
76 |
+
}
|
77 |
+
?>
|
78 |
+
</select> <img class="help_tip" data-tip='<?php _e( 'One of these shipping methods must be selected in order for this coupon to be valid.', 'woocommerce-jos-autocoupon' ); ?>' src="<?php echo WC()->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
|
79 |
+
<?php
|
80 |
+
|
81 |
+
// Payment methods
|
82 |
+
?>
|
83 |
+
<p class="form-field"><label for="wjecf_payment_methods"><?php _e( 'Payment methods', 'woocommerce-jos-autocoupon' ); ?></label>
|
84 |
+
<select id="wjecf_payment_methods" name="wjecf_payment_methods[]" style="width: 50%;" class="wc-enhanced-select" multiple="multiple" data-placeholder="<?php _e( 'Any shipping method', 'woocommerce-jos-autocoupon' ); ?>">
|
85 |
+
<?php
|
86 |
+
$payment_method_ids = (array) get_post_meta( $thepostid, '_wjecf_payment_methods', true );
|
87 |
+
//DONT USE: CAN CRASH IN UNKNOWN OCCASIONS // $payment_methods = WC()->payment_gateways->available_payment_gateways();
|
88 |
+
$payment_methods = WC()->payment_gateways->payment_gateways();
|
89 |
+
if ( $payment_methods ) foreach ( $payment_methods as $payment_method ) {
|
90 |
+
if ('yes' === $payment_method->enabled) {
|
91 |
+
echo '<option value="' . esc_attr( $payment_method->id ) . '"' . selected( in_array( $payment_method->id, $payment_method_ids ), true, false ) . '>' . esc_html( $payment_method->title ) . '</option>';
|
92 |
+
}
|
93 |
+
}
|
94 |
+
?>
|
95 |
+
</select> <img class="help_tip" data-tip='<?php _e( 'One of these payment methods must be selected in order for this coupon to be valid.', 'woocommerce-jos-autocoupon' ); ?>' src="<?php echo WC()->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
|
96 |
+
<?php
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
public function process_shop_coupon_meta( $post_id, $post ) {
|
101 |
+
$wjecf_products_and = isset( $_POST['_wjecf_products_and'] ) ? 'yes' : 'no';
|
102 |
+
update_post_meta( $post_id, '_wjecf_products_and', $wjecf_products_and );
|
103 |
+
|
104 |
+
$wjecf_shipping_methods = isset( $_POST['wjecf_shipping_methods'] ) ? $_POST['wjecf_shipping_methods'] : '';
|
105 |
+
update_post_meta( $post_id, '_wjecf_shipping_methods', $wjecf_shipping_methods );
|
106 |
+
|
107 |
+
$wjecf_payment_methods = isset( $_POST['wjecf_payment_methods'] ) ? $_POST['wjecf_payment_methods'] : '';
|
108 |
+
update_post_meta( $post_id, '_wjecf_payment_methods', $wjecf_payment_methods );
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
/* FRONTEND HOOKS */
|
113 |
+
|
114 |
+
/* Extra validation rules for coupons */
|
115 |
+
function coupon_is_valid ( $valid, $coupon ) {
|
116 |
+
//Not valid? Then it will never validate, so get out of here
|
117 |
+
if ( ! $valid ) {
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
|
121 |
+
//Test if ALL products are in the cart (if AND-operator selected in stead of the default OR)
|
122 |
+
$products_and = get_post_meta( $coupon->id, '_wjecf_products_and', true ) == 'yes';
|
123 |
+
if ( $products_and && sizeof( $coupon->product_ids ) > 1 ) { // We use > 1, because if size == 1, 'AND' makes no difference
|
124 |
+
//Get array of all cart product and variation ids
|
125 |
+
$cart_item_ids = array();
|
126 |
+
foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
127 |
+
$cart_item_ids[] = $cart_item['product_id'];
|
128 |
+
$cart_item_ids[] = $cart_item['variation_id'];
|
129 |
+
}
|
130 |
+
//check if every single product is in the cart
|
131 |
+
foreach( $coupon->product_ids as $product_id ) {
|
132 |
+
if ( ! in_array( $product_id, $cart_item_ids ) ) {
|
133 |
+
return false;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
|
139 |
+
//Test restricted shipping methods
|
140 |
+
$shipping_method_ids = $this->get_shipping_method_ids( $coupon );
|
141 |
+
if ( sizeof( $shipping_method_ids ) > 0 ) {
|
142 |
+
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
|
143 |
+
$chosen_shipping = $chosen_shipping_methods[0];
|
144 |
+
|
145 |
+
if ( ! in_array( $chosen_shipping, $shipping_method_ids ) ) {
|
146 |
+
return false;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
//Test restricted payment methods
|
151 |
+
$payment_method_ids = $this->get_payment_method_ids( $coupon );
|
152 |
+
if ( sizeof( $payment_method_ids ) > 0 ) {
|
153 |
+
$chosen_payment_method = isset( WC()->session->chosen_payment_method ) ? WC()->session->chosen_payment_method : array();
|
154 |
+
|
155 |
+
if ( ! in_array( $chosen_payment_method, $payment_method_ids ) ) {
|
156 |
+
return false;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
return true;
|
161 |
+
}
|
162 |
+
|
163 |
+
//
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Get array of the selected shipping methods ids.
|
167 |
+
* @param WC_Coupon $coupon The coupon data
|
168 |
+
* @return array Id's of the shipping methods or an empty array.
|
169 |
+
*/
|
170 |
+
private function get_shipping_method_ids($coupon) {
|
171 |
+
$v = get_post_meta( $coupon->id, '_wjecf_shipping_methods', true );
|
172 |
+
if ($v == '') {
|
173 |
+
$v = array();
|
174 |
+
}
|
175 |
+
|
176 |
+
return $v;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Get array of the selected payment method ids.
|
181 |
+
* @param WC_Coupon $coupon The coupon data
|
182 |
+
* @return array Id's of the payment methods or an empty array.
|
183 |
+
*/
|
184 |
+
private function get_payment_method_ids($coupon) {
|
185 |
+
$v = get_post_meta( $coupon->id, '_wjecf_payment_methods', true );
|
186 |
+
if ($v == '') {
|
187 |
+
$v = array();
|
188 |
+
}
|
189 |
+
|
190 |
+
return $v;
|
191 |
+
}
|
192 |
+
|
193 |
+
public static function get_donate_url() {
|
194 |
+
return "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQBCS2QHRY&lc=NL&item_name=Jos%20Koenis&item_number=wordpress%2dplugin¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted";
|
195 |
+
}
|
196 |
+
|
197 |
+
}
|
languages/woocommerce-jos-autocoupon-de_DE.mo
CHANGED
Binary file
|
languages/woocommerce-jos-autocoupon-de_DE.po
CHANGED
@@ -5,50 +5,68 @@ msgstr ""
|
|
5 |
"Project-Id-Version: WooCommerce auto added coupons 1.1.3.1\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/woocommerce-auto-"
|
7 |
"added-coupons\n"
|
8 |
-
"POT-Creation-Date: 2015-03
|
|
|
|
|
|
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"
|
13 |
-
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
-
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
-
"X-Generator: Poedit 1.5.4\n"
|
16 |
|
17 |
-
#: woocommerce-
|
18 |
msgid "Auto coupon"
|
19 |
msgstr "Automatisch einlösen"
|
20 |
|
21 |
-
#: woocommerce-
|
22 |
msgid ""
|
23 |
"Automatically add the coupon to the cart if the restrictions are met. Please "
|
24 |
"enter a description when you check this box, the description will be shown "
|
25 |
-
"in the customers cart if the coupon is applied.
|
26 |
-
"added coupons plugin)."
|
27 |
msgstr ""
|
28 |
"Diesen Coupon im Warenkorb automatisch einlösen, wenn die Bedingungen "
|
29 |
"erfüllt wurden. Bitte geben Sie eine Beschreibung ein. Wenn Sie das Häkchen "
|
30 |
"setzen wird die Beschreibung im Warenkorb des Nutzers angezeigt, sobald der "
|
31 |
-
"Coupon eingelöst wurde.
|
32 |
|
33 |
-
#: woocommerce-
|
|
|
|
|
|
|
|
|
|
|
34 |
msgid "Discount applied: %s"
|
35 |
msgstr "Automatischer Rabatt: %s"
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
msgid ""
|
42 |
-
"
|
43 |
-
"
|
44 |
msgstr ""
|
45 |
-
"Ermöglicht Coupons automatisch im Warenkorb einzulösen, wenn bestimmte "
|
46 |
-
"Bedinungen erfüllt sind. Coupons können auch via URL einlösbar gemacht "
|
47 |
-
"werden."
|
48 |
|
49 |
-
|
50 |
-
|
|
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
5 |
"Project-Id-Version: WooCommerce auto added coupons 1.1.3.1\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/woocommerce-auto-"
|
7 |
"added-coupons\n"
|
8 |
+
"POT-Creation-Date: 2015-05-03 21:01+0100\n"
|
9 |
+
"PO-Revision-Date: 2015-05-04 23:21+0100\n"
|
10 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
11 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
12 |
"MIME-Version: 1.0\n"
|
13 |
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
"Content-Transfer-Encoding: 8bit\n"
|
15 |
+
"X-Generator: Poedit 1.5.7\n"
|
|
|
|
|
|
|
16 |
|
17 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:49
|
18 |
msgid "Auto coupon"
|
19 |
msgstr "Automatisch einlösen"
|
20 |
|
21 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:50
|
22 |
msgid ""
|
23 |
"Automatically add the coupon to the cart if the restrictions are met. Please "
|
24 |
"enter a description when you check this box, the description will be shown "
|
25 |
+
"in the customers cart if the coupon is applied."
|
|
|
26 |
msgstr ""
|
27 |
"Diesen Coupon im Warenkorb automatisch einlösen, wenn die Bedingungen "
|
28 |
"erfüllt wurden. Bitte geben Sie eine Beschreibung ein. Wenn Sie das Häkchen "
|
29 |
"setzen wird die Beschreibung im Warenkorb des Nutzers angezeigt, sobald der "
|
30 |
+
"Coupon eingelöst wurde."
|
31 |
|
32 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:111
|
33 |
+
msgid "Free shipping coupon"
|
34 |
+
msgstr "Gratis verzending kortingsbon"
|
35 |
+
|
36 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:218
|
37 |
+
#, php-format
|
38 |
msgid "Discount applied: %s"
|
39 |
msgstr "Automatischer Rabatt: %s"
|
40 |
|
41 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:32
|
42 |
+
msgid "Extended Coupon Features"
|
43 |
+
msgstr ""
|
44 |
+
|
45 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:34
|
46 |
+
msgid "Donate to the developer"
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:39
|
50 |
+
msgid "Shipping methods"
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:40
|
54 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:55
|
55 |
+
msgid "Any shipping method"
|
56 |
+
msgstr ""
|
57 |
+
|
58 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:49
|
59 |
msgid ""
|
60 |
+
"One of these shipping methods must be selected in order for this coupon to "
|
61 |
+
"be valid."
|
62 |
msgstr ""
|
|
|
|
|
|
|
63 |
|
64 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:54
|
65 |
+
msgid "Payment methods"
|
66 |
+
msgstr ""
|
67 |
|
68 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:64
|
69 |
+
msgid ""
|
70 |
+
"One of these payment methods must be selected in order for this coupon to be "
|
71 |
+
"valid."
|
72 |
+
msgstr ""
|
languages/woocommerce-jos-autocoupon-es_ES.mo
CHANGED
Binary file
|
languages/woocommerce-jos-autocoupon-es_ES.po
CHANGED
@@ -5,53 +5,104 @@ msgstr ""
|
|
5 |
"Project-Id-Version: WooCommerce auto added coupons 1.1.3.1\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/woocommerce-auto-"
|
7 |
"added-coupons\n"
|
8 |
-
"POT-Creation-Date: 2015-
|
|
|
|
|
|
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"
|
13 |
-
"
|
14 |
-
"
|
|
|
15 |
|
16 |
-
#: woocommerce-
|
17 |
msgid "Auto coupon"
|
18 |
msgstr "Aplicar cupón automaticamente"
|
19 |
|
20 |
-
#: woocommerce-
|
21 |
msgid ""
|
22 |
"Automatically add the coupon to the cart if the restrictions are met. Please "
|
23 |
"enter a description when you check this box, the description will be shown "
|
24 |
-
"in the customers cart if the coupon is applied.
|
25 |
-
"added coupons plugin)."
|
26 |
msgstr ""
|
27 |
"Aplicar el cupón automaticamente al carrito de compras cuando los requisitos "
|
28 |
-
"sean cumplidos. Por favor ingrese una descripción, ya que este será mostrado
|
29 |
-
"cliente cuando el cupón esté aplicado.
|
30 |
|
31 |
-
#: woocommerce-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
-
#: woocommerce-
|
|
|
36 |
msgid "Discount applied: %s"
|
37 |
msgstr "Descuento aplicado: %s"
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
44 |
-
msgid "
|
|
|
|
|
45 |
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
|
48 |
msgid ""
|
49 |
-
"
|
50 |
-
"
|
51 |
msgstr ""
|
52 |
-
"
|
53 |
-
"
|
54 |
|
55 |
-
|
56 |
-
#~
|
|
|
57 |
#~ msgstr ""
|
|
|
|
|
|
|
|
|
|
5 |
"Project-Id-Version: WooCommerce auto added coupons 1.1.3.1\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/woocommerce-auto-"
|
7 |
"added-coupons\n"
|
8 |
+
"POT-Creation-Date: 2015-05-04 23:28+0100\n"
|
9 |
+
"PO-Revision-Date: 2015-05-04 23:32+0100\n"
|
10 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
11 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
12 |
"MIME-Version: 1.0\n"
|
13 |
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
"Content-Transfer-Encoding: 8bit\n"
|
15 |
+
"X-Generator: Poedit 1.5.7\n"
|
16 |
+
"X-Poedit-KeywordsList: __;_e\n"
|
17 |
+
"X-Poedit-Basepath: C:\\lamp\\www\\qrvm_woo\\wp-content\\plugins\\\n"
|
18 |
+
"X-Poedit-SearchPath-0: woocommerce-auto-added-coupons\n"
|
19 |
|
20 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:49
|
21 |
msgid "Auto coupon"
|
22 |
msgstr "Aplicar cupón automaticamente"
|
23 |
|
24 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:50
|
25 |
msgid ""
|
26 |
"Automatically add the coupon to the cart if the restrictions are met. Please "
|
27 |
"enter a description when you check this box, the description will be shown "
|
28 |
+
"in the customers cart if the coupon is applied."
|
|
|
29 |
msgstr ""
|
30 |
"Aplicar el cupón automaticamente al carrito de compras cuando los requisitos "
|
31 |
+
"sean cumplidos. Por favor ingrese una descripción, ya que este será mostrado "
|
32 |
+
"al cliente cuando el cupón esté aplicado."
|
33 |
|
34 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:111
|
35 |
+
msgid "Free shipping coupon"
|
36 |
+
msgstr "Cupón para envío gratis"
|
37 |
|
38 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:222
|
39 |
+
#, php-format
|
40 |
msgid "Discount applied: %s"
|
41 |
msgstr "Descuento aplicado: %s"
|
42 |
|
43 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:34
|
44 |
+
msgid "Extended Coupon Features"
|
45 |
+
msgstr "Más opciones para cupones"
|
46 |
+
|
47 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:36
|
48 |
+
msgid "Donate to the developer"
|
49 |
+
msgstr "Hacer una donación"
|
50 |
+
|
51 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:42
|
52 |
+
msgid "AND Products (not OR)"
|
53 |
+
msgstr "TODOS los productos"
|
54 |
+
|
55 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:43
|
56 |
+
msgid ""
|
57 |
+
"Check this box if ALL of the products (see above) must be in the cart to use "
|
58 |
+
"this coupon (in stead of only one of the products)."
|
59 |
+
msgstr ""
|
60 |
+
"Marque esta casilla si TODOS los productos (ve arriba) tienen que estar en "
|
61 |
+
"el carrito para poder usar este cupón (en lugar de solo uno de los "
|
62 |
+
"productos)."
|
63 |
+
|
64 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:48
|
65 |
+
msgid "(AND)"
|
66 |
+
msgstr "(TODOS)"
|
67 |
+
|
68 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:49
|
69 |
+
msgid "(OR)"
|
70 |
+
msgstr "(UNO)"
|
71 |
+
|
72 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:68
|
73 |
+
msgid "Shipping methods"
|
74 |
+
msgstr "Métodos de envío"
|
75 |
+
|
76 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:69
|
77 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:84
|
78 |
+
msgid "Any shipping method"
|
79 |
+
msgstr "Métodos de pago"
|
80 |
|
81 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:78
|
82 |
+
msgid ""
|
83 |
+
"One of these shipping methods must be selected in order for this coupon to "
|
84 |
+
"be valid."
|
85 |
msgstr ""
|
86 |
+
"Uno de estos métodos de pago tiene que ser seleccionado para usar este cupón."
|
87 |
+
|
88 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:83
|
89 |
+
msgid "Payment methods"
|
90 |
+
msgstr "Métodos de pago"
|
91 |
|
92 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:95
|
93 |
msgid ""
|
94 |
+
"One of these payment methods must be selected in order for this coupon to be "
|
95 |
+
"valid."
|
96 |
msgstr ""
|
97 |
+
"Uno de estos métodos de envío tiene que ser seleccionado para usar este "
|
98 |
+
"cupón."
|
99 |
|
100 |
+
#~ msgid ""
|
101 |
+
#~ "Allow discounts to be automatically added to the cart when it's "
|
102 |
+
#~ "restrictions are met. Allow applying coupons via an url."
|
103 |
#~ msgstr ""
|
104 |
+
#~ "Aplicar ciertos cupónes automaticamente al carrito de compras cuando los "
|
105 |
+
#~ "requisitos sean cumplidos. Aplicar cupones a través de la url. "
|
106 |
+
|
107 |
+
#~ msgid "WooCommerce auto added coupons"
|
108 |
+
#~ msgstr "WooCommerce auto added coupons"
|
languages/woocommerce-jos-autocoupon-nb_NO.mo
ADDED
Binary file
|
languages/woocommerce-jos-autocoupon-nb_NO.po
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2015 WooCommerce auto added coupons
|
2 |
+
# This file is distributed under the same license as the WooCommerce auto added coupons package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: WooCommerce auto added coupons 1.1.3.1\n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/woocommerce-auto-"
|
7 |
+
"added-coupons\n"
|
8 |
+
"POT-Creation-Date: 2015-05-04 23:49+0100\n"
|
9 |
+
"PO-Revision-Date: 2015-05-04 23:49+0100\n"
|
10 |
+
"Last-Translator: Anders Sorensen <anders@zorensen.no>\n"
|
11 |
+
"Language-Team: \n"
|
12 |
+
"Language: nb\n"
|
13 |
+
"MIME-Version: 1.0\n"
|
14 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
+
"Content-Transfer-Encoding: 8bit\n"
|
16 |
+
"X-Generator: Poedit 1.5.7\n"
|
17 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
18 |
+
"X-Poedit-KeywordsList: __;_e\n"
|
19 |
+
"X-Poedit-Basepath: C:\\lamp\\www\\qrvm_woo\\wp-content\\plugins\\\n"
|
20 |
+
"X-Poedit-SearchPath-0: woocommerce-auto-added-coupons\n"
|
21 |
+
|
22 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:49
|
23 |
+
msgid "Auto coupon"
|
24 |
+
msgstr "Automatisk rabattkupong"
|
25 |
+
|
26 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:50
|
27 |
+
msgid ""
|
28 |
+
"Automatically add the coupon to the cart if the restrictions are met. Please "
|
29 |
+
"enter a description when you check this box, the description will be shown "
|
30 |
+
"in the customers cart if the coupon is applied."
|
31 |
+
msgstr ""
|
32 |
+
"Legg rabattkupong automatisk til handlekurven om kravene er oppfylt. "
|
33 |
+
"Vennligst skriv inn en beskrivelse når du velger denne boksen. Beskrivelsen "
|
34 |
+
"vil bli vist i handlekurven om rabattkupongen blir lagt til."
|
35 |
+
|
36 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:111
|
37 |
+
msgid "Free shipping coupon"
|
38 |
+
msgstr "Gratis frakt kupong"
|
39 |
+
|
40 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:222
|
41 |
+
#, php-format
|
42 |
+
msgid "Discount applied: %s"
|
43 |
+
msgstr "Rabatt: %s"
|
44 |
+
|
45 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:34
|
46 |
+
msgid "Extended Coupon Features"
|
47 |
+
msgstr "Utvidet kupong funksjoner"
|
48 |
+
|
49 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:36
|
50 |
+
msgid "Donate to the developer"
|
51 |
+
msgstr "Donèr til utvikleren"
|
52 |
+
|
53 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:42
|
54 |
+
msgid "AND Products (not OR)"
|
55 |
+
msgstr ""
|
56 |
+
|
57 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:43
|
58 |
+
msgid ""
|
59 |
+
"Check this box if ALL of the products (see above) must be in the cart to use "
|
60 |
+
"this coupon (in stead of only one of the products)."
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:48
|
64 |
+
msgid "(AND)"
|
65 |
+
msgstr ""
|
66 |
+
|
67 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:49
|
68 |
+
msgid "(OR)"
|
69 |
+
msgstr ""
|
70 |
+
|
71 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:68
|
72 |
+
msgid "Shipping methods"
|
73 |
+
msgstr "Fraktmetoder"
|
74 |
+
|
75 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:69
|
76 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:84
|
77 |
+
msgid "Any shipping method"
|
78 |
+
msgstr "Alle metoder"
|
79 |
+
|
80 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:78
|
81 |
+
msgid ""
|
82 |
+
"One of these shipping methods must be selected in order for this coupon to "
|
83 |
+
"be valid."
|
84 |
+
msgstr ""
|
85 |
+
"En av disse faktmetodene må være valgt for at denne kupongen skal være "
|
86 |
+
"gyldig."
|
87 |
+
|
88 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:83
|
89 |
+
msgid "Payment methods"
|
90 |
+
msgstr "Betalingsmåter"
|
91 |
+
|
92 |
+
#: woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:95
|
93 |
+
msgid ""
|
94 |
+
"One of these payment methods must be selected in order for this coupon to be "
|
95 |
+
"valid."
|
96 |
+
msgstr ""
|
97 |
+
"En av disse betalingsmetodene må være valgt for at denne kupongen skal være "
|
98 |
+
"valgt."
|
languages/woocommerce-jos-autocoupon-nl_NL.mo
CHANGED
Binary file
|
languages/woocommerce-jos-autocoupon-nl_NL.po
CHANGED
@@ -5,54 +5,96 @@ msgstr ""
|
|
5 |
"Project-Id-Version: WooCommerce auto added coupons 1.1.3.1\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/woocommerce-auto-"
|
7 |
"added-coupons\n"
|
8 |
-
"POT-Creation-Date: 2015-
|
|
|
|
|
|
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"
|
13 |
-
"
|
14 |
-
"
|
|
|
|
|
15 |
|
16 |
-
#: woocommerce-
|
17 |
msgid "Auto coupon"
|
18 |
msgstr "Automatisch toepassen"
|
19 |
|
20 |
-
#: woocommerce-
|
21 |
msgid ""
|
22 |
"Automatically add the coupon to the cart if the restrictions are met. Please "
|
23 |
"enter a description when you check this box, the description will be shown "
|
24 |
-
"in the customers cart if the coupon is applied.
|
25 |
-
"added coupons plugin)."
|
26 |
msgstr ""
|
27 |
-
"Voeg de kortingsbon automatisch toe aan het winkelwagentje als aan alle
|
28 |
-
"wordt voldaan. Vult u a.u.b. een omschrijving in als u deze
|
29 |
-
"omschrijving zal aan de klant worden getoond wanneer de
|
30 |
-
"
|
31 |
|
32 |
-
#: woocommerce-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
#: woocommerce-
|
|
|
37 |
msgid "Discount applied: %s"
|
38 |
msgstr "Korting toegepast: %s"
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
49 |
msgid ""
|
50 |
-
"
|
51 |
-
"
|
52 |
msgstr ""
|
53 |
-
"
|
54 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
"Project-Id-Version: WooCommerce auto added coupons 1.1.3.1\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/woocommerce-auto-"
|
7 |
"added-coupons\n"
|
8 |
+
"POT-Creation-Date: 2015-05-04 23:22+0100\n"
|
9 |
+
"PO-Revision-Date: 2015-05-05 00:19+0100\n"
|
10 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
11 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
12 |
"MIME-Version: 1.0\n"
|
13 |
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
"Content-Transfer-Encoding: 8bit\n"
|
15 |
+
"X-Generator: Poedit 1.5.7\n"
|
16 |
+
"X-Poedit-KeywordsList: __;_e\n"
|
17 |
+
"X-Poedit-Basepath: .\n"
|
18 |
+
"X-Poedit-SearchPath-0: C:\\lamp\\www\\qrvm_woo\\wp-content\\plugins"
|
19 |
+
"\\woocommerce-auto-added-coupons\n"
|
20 |
|
21 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:49
|
22 |
msgid "Auto coupon"
|
23 |
msgstr "Automatisch toepassen"
|
24 |
|
25 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:50
|
26 |
msgid ""
|
27 |
"Automatically add the coupon to the cart if the restrictions are met. Please "
|
28 |
"enter a description when you check this box, the description will be shown "
|
29 |
+
"in the customers cart if the coupon is applied."
|
|
|
30 |
msgstr ""
|
31 |
+
"Voeg de kortingsbon automatisch toe aan het winkelwagentje als aan alle "
|
32 |
+
"voorwaarden wordt voldaan. Vult u a.u.b. een omschrijving in als u deze "
|
33 |
+
"optie aanvinkt, de omschrijving zal aan de klant worden getoond wanneer de "
|
34 |
+
"kortingsbon wordt toegevoegd."
|
35 |
|
36 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:111
|
37 |
+
msgid "Free shipping coupon"
|
38 |
+
msgstr "Gratis verzending kortingsbon"
|
39 |
|
40 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:222
|
41 |
+
#, php-format
|
42 |
msgid "Discount applied: %s"
|
43 |
msgstr "Korting toegepast: %s"
|
44 |
|
45 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:34
|
46 |
+
msgid "Extended Coupon Features"
|
47 |
+
msgstr "Uitgebreide Kortingsbon Eigenschappen"
|
48 |
|
49 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:36
|
50 |
+
msgid "Donate to the developer"
|
51 |
+
msgstr "Doneer aan de ontwikkelaar"
|
52 |
|
53 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:42
|
54 |
+
msgid "AND Products (not OR)"
|
55 |
+
msgstr "ALLE Producten (niet OF)"
|
56 |
+
|
57 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:43
|
58 |
msgid ""
|
59 |
+
"Check this box if ALL of the products (see above) must be in the cart to use "
|
60 |
+
"this coupon (in stead of only one of the products)."
|
61 |
msgstr ""
|
62 |
+
"Aanvinken als ALLE producten (zie boven) in de winkelwagen moeten zitten om "
|
63 |
+
"deze kortingsbon te kunnen gebruiken (in plaats van één van de producten)."
|
64 |
+
|
65 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:48
|
66 |
+
msgid "(AND)"
|
67 |
+
msgstr "(ALLE)"
|
68 |
+
|
69 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:49
|
70 |
+
msgid "(OR)"
|
71 |
+
msgstr "(OF)"
|
72 |
+
|
73 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:68
|
74 |
+
msgid "Shipping methods"
|
75 |
+
msgstr "Verzendmethoden"
|
76 |
|
77 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:69
|
78 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:84
|
79 |
+
msgid "Any shipping method"
|
80 |
+
msgstr "Verzendmethoden"
|
81 |
+
|
82 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:78
|
83 |
+
msgid ""
|
84 |
+
"One of these shipping methods must be selected in order for this coupon to "
|
85 |
+
"be valid."
|
86 |
+
msgstr ""
|
87 |
+
"Een van deze verzendmethoden moet gekozen zijn om deze kortingsbon te kunnen "
|
88 |
+
"gebruiken."
|
89 |
+
|
90 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:83
|
91 |
+
msgid "Payment methods"
|
92 |
+
msgstr "Betaalmethoden"
|
93 |
+
|
94 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:95
|
95 |
+
msgid ""
|
96 |
+
"One of these payment methods must be selected in order for this coupon to be "
|
97 |
+
"valid."
|
98 |
+
msgstr ""
|
99 |
+
"Een van deze betaalmethoden moet gekozen zijn om deze kortingsbon te kunnen "
|
100 |
+
"gebruiken."
|
languages/woocommerce-jos-autocoupon.pot
CHANGED
@@ -1,52 +1,70 @@
|
|
1 |
-
# Copyright (C) 2015 WooCommerce auto added coupons
|
2 |
-
# This file is distributed under the same license as the WooCommerce auto added coupons package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: WooCommerce
|
6 |
-
"
|
7 |
-
"
|
8 |
-
"
|
|
|
|
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"
|
13 |
-
"
|
14 |
-
"
|
|
|
|
|
|
|
15 |
|
16 |
-
#: woocommerce-
|
17 |
msgid "Auto coupon"
|
18 |
msgstr ""
|
19 |
|
20 |
-
#: woocommerce-
|
21 |
msgid ""
|
22 |
"Automatically add the coupon to the cart if the restrictions are met. Please "
|
23 |
"enter a description when you check this box, the description will be shown "
|
24 |
-
"in the customers cart if the coupon is applied.
|
25 |
-
"added coupons plugin)."
|
26 |
msgstr ""
|
27 |
|
28 |
-
#: woocommerce-
|
29 |
msgid "Free shipping coupon"
|
30 |
msgstr ""
|
31 |
|
32 |
-
#: woocommerce-
|
|
|
33 |
msgid "Discount applied: %s"
|
34 |
msgstr ""
|
35 |
|
36 |
-
|
37 |
-
msgid "
|
38 |
msgstr ""
|
39 |
|
40 |
-
|
41 |
-
msgid "
|
42 |
msgstr ""
|
43 |
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
msgid ""
|
46 |
-
"
|
47 |
-
"
|
48 |
msgstr ""
|
49 |
|
50 |
-
|
51 |
-
msgid "
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
msgstr ""
|
|
|
|
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
+
"Project-Id-Version: WooCommerce Extended Coupon Features 2.00\n"
|
4 |
+
"POT-Creation-Date: 2015-05-03 21:01+0100\n"
|
5 |
+
"PO-Revision-Date: 2015-05-03 21:02+0100\n"
|
6 |
+
"Last-Translator: \n"
|
7 |
+
"Language-Team: Jos Koenis\n"
|
8 |
+
"Language: EN\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Generator: Poedit 1.5.7\n"
|
13 |
+
"X-Poedit-KeywordsList: __;_e\n"
|
14 |
+
"X-Poedit-Basepath: .\n"
|
15 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
+
"X-Poedit-SearchPath-0: C:\\lamp\\www\\qrvm_woo\\wp-content\\plugins"
|
17 |
+
"\\woocommerce-auto-added-coupons\n"
|
18 |
|
19 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:49
|
20 |
msgid "Auto coupon"
|
21 |
msgstr ""
|
22 |
|
23 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:50
|
24 |
msgid ""
|
25 |
"Automatically add the coupon to the cart if the restrictions are met. Please "
|
26 |
"enter a description when you check this box, the description will be shown "
|
27 |
+
"in the customers cart if the coupon is applied."
|
|
|
28 |
msgstr ""
|
29 |
|
30 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:111
|
31 |
msgid "Free shipping coupon"
|
32 |
msgstr ""
|
33 |
|
34 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-autocoupon.php:218
|
35 |
+
#, php-format
|
36 |
msgid "Discount applied: %s"
|
37 |
msgstr ""
|
38 |
|
39 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:32
|
40 |
+
msgid "Extended Coupon Features"
|
41 |
msgstr ""
|
42 |
|
43 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:34
|
44 |
+
msgid "Donate to the developer"
|
45 |
msgstr ""
|
46 |
|
47 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:39
|
48 |
+
msgid "Shipping methods"
|
49 |
+
msgstr ""
|
50 |
+
|
51 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:40
|
52 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:55
|
53 |
+
msgid "Any shipping method"
|
54 |
+
msgstr ""
|
55 |
+
|
56 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:49
|
57 |
msgid ""
|
58 |
+
"One of these shipping methods must be selected in order for this coupon to "
|
59 |
+
"be valid."
|
60 |
msgstr ""
|
61 |
|
62 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:54
|
63 |
+
msgid "Payment methods"
|
64 |
+
msgstr ""
|
65 |
+
|
66 |
+
#: C:\lamp\www\qrvm_woo\wp-content\plugins\woocommerce-auto-added-coupons/includes/wjecf-coupon-extensions.php:64
|
67 |
+
msgid ""
|
68 |
+
"One of these payment methods must be selected in order for this coupon to be "
|
69 |
+
"valid."
|
70 |
msgstr ""
|
readme.txt
CHANGED
@@ -2,41 +2,47 @@
|
|
2 |
Contributors: josk79
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQBCS2QHRY&lc=NL&item_name=Jos%20Koenis&item_number=wordpress%2dplugin¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
|
4 |
Tags: woocommerce, coupons, discount
|
5 |
-
Requires at least:
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
Allow applying coupons
|
12 |
-
Allow discounts to be automatically added to the WooCommerce cart when it's restrictions are met.
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
-
"WooCommerce
|
17 |
-
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
**Example**: Let the customer have a discount of $ 5.00 when the cart reaches $ 50.00.
|
26 |
|
27 |
1. Create a coupon, let's name it *auto_50bucks* and enter a short description e.g. *$ 50.00 order discount*
|
28 |
2. On the General tab: Select discount type *Cart discount*, and set the coupon amount to $ 5.00
|
29 |
3. On the Usage restrictions tab: Set minimum spend to $ 50.00 and check the *Auto coupon*-box
|
30 |
|
31 |
-
Voila! The discount will be applied when the customer reaches $ 50.00.
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
|
34 |
|
35 |
1. Use the url www.example.com/url-to-shop?apply_coupon=my_coupon
|
36 |
|
37 |
Voila! Any coupon can be applied this way.
|
38 |
|
39 |
-
|
|
|
40 |
|
41 |
== Installation ==
|
42 |
|
@@ -60,6 +66,22 @@ Yes, all frontend string values are translatable with WPML. Translatable items a
|
|
60 |
|
61 |
The coupon will only be applied if the url links to a WooCommerce page (e.g. product loop / cart / product detail ).
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
= Can I make a donation? =
|
64 |
|
65 |
Sure! [This](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQBCS2QHRY&lc=NL&item_name=Jos%20Koenis&item_number=wordpress%2dplugin¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted) is the link. Greatly appreciated!
|
@@ -69,6 +91,14 @@ Sure! [This](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQ
|
|
69 |
1. Simply use the WooCommerce Coupons menu to make a coupon an "auto coupon".
|
70 |
|
71 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
= 1.1.5 =
|
73 |
* FIX: Cart total discount amount showing wrong discount value in newer WooCommerce versions (tax)
|
74 |
* Performance: get_all_auto_coupons select only where meta woocommerce_jos_autocoupon = yes (Thanks to ircary)
|
@@ -99,4 +129,11 @@ Sure! [This](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQ
|
|
99 |
|
100 |
= 1.0 =
|
101 |
* First version ever!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
2 |
Contributors: josk79
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQBCS2QHRY&lc=NL&item_name=Jos%20Koenis&item_number=wordpress%2dplugin¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
|
4 |
Tags: woocommerce, coupons, discount
|
5 |
+
Requires at least: 4.0.0
|
6 |
+
Tested up to: 4.2.4
|
7 |
+
Stable tag: 2.0.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
Additional functionality for WooCommerce Coupons: Allow discounts to be automatically applied, applying coupons via url, etc...
|
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
"WooCommerce Extended Coupon Features" (formerly known as: WooCommerce auto added coupons) adds functionality to the WooCommerce coupons.
|
16 |
+
Very easy to use, the functionality is conveniently integrated to the WooCommerce Edit Coupon panel.
|
17 |
|
18 |
+
* *Auto coupons*: Allow coupons to be automatically added to the users cart if it's restrictions are met,
|
19 |
+
* Apply coupon via an url,
|
20 |
+
* Restrict coupon by shipping method,
|
21 |
+
* Restrict coupon by payment method,
|
22 |
+
* Restrict coupon by a combination of products
|
23 |
|
24 |
+
= Example: Auto coupon =
|
25 |
|
26 |
+
Let the customer have a discount of $ 5.00 when the cart reaches $ 50.00.
|
|
|
|
|
27 |
|
28 |
1. Create a coupon, let's name it *auto_50bucks* and enter a short description e.g. *$ 50.00 order discount*
|
29 |
2. On the General tab: Select discount type *Cart discount*, and set the coupon amount to $ 5.00
|
30 |
3. On the Usage restrictions tab: Set minimum spend to $ 50.00 and check the *Auto coupon*-box
|
31 |
|
32 |
+
Voila! The discount will be applied when the customer reaches $ 50.00 and a descriptive message will be shown.
|
33 |
+
|
34 |
+
If the restrictions are no longer met, it will silently be removed from the cart.
|
35 |
+
|
36 |
+
= Example: Apply coupon via an URL =
|
37 |
|
38 |
+
Apply coupon through an url like this:
|
39 |
|
40 |
1. Use the url www.example.com/url-to-shop?apply_coupon=my_coupon
|
41 |
|
42 |
Voila! Any coupon can be applied this way.
|
43 |
|
44 |
+
|
45 |
+
This plugin has been tested with WordPress 4.2.4 and WooCommerce 2.4.1. Also in combination with WPML and qTranslate-X.
|
46 |
|
47 |
== Installation ==
|
48 |
|
66 |
|
67 |
The coupon will only be applied if the url links to a WooCommerce page (e.g. product loop / cart / product detail ).
|
68 |
|
69 |
+
= The cart is not updated after changing the payment method =
|
70 |
+
|
71 |
+
In your theme add class "update_totals_on_change" to the container (div / p / whatever) that holds the payment method radio buttons.
|
72 |
+
You can do this by overriding woocommerce/templates/checkout/payment.php (place it in your_template/woocommerce/checkout/).
|
73 |
+
|
74 |
+
= The cart is not updated after changing the billing email address =
|
75 |
+
|
76 |
+
Paste this snippet in your theme's functions.php:
|
77 |
+
`
|
78 |
+
//Update the cart preview when the billing email is changed by the customer
|
79 |
+
add_filter( 'woocommerce_checkout_fields', function( $checkout_fields ) {
|
80 |
+
$checkout_fields['billing']['billing_email']['class'][] = 'update_totals_on_change';
|
81 |
+
return $checkout_fields;
|
82 |
+
} );
|
83 |
+
`
|
84 |
+
|
85 |
= Can I make a donation? =
|
86 |
|
87 |
Sure! [This](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQBCS2QHRY&lc=NL&item_name=Jos%20Koenis&item_number=wordpress%2dplugin¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted) is the link. Greatly appreciated!
|
91 |
1. Simply use the WooCommerce Coupons menu to make a coupon an "auto coupon".
|
92 |
|
93 |
== Changelog ==
|
94 |
+
= 2.0.0 =
|
95 |
+
* RENAME: Renamed plugin from "WooCommerce auto added coupons" to "WooCommerce Extended Coupon Features"
|
96 |
+
* FEATURE: Restrict coupons by payment method
|
97 |
+
* FEATURE: Restrict coupons by shipping method
|
98 |
+
* FEATURE: Use AND-operator for the selected products (default is OR)
|
99 |
+
* FIX: Validate email restrictions for auto coupons
|
100 |
+
* Norwegian translation added (Thanks to Anders Zorensen)
|
101 |
+
|
102 |
= 1.1.5 =
|
103 |
* FIX: Cart total discount amount showing wrong discount value in newer WooCommerce versions (tax)
|
104 |
* Performance: get_all_auto_coupons select only where meta woocommerce_jos_autocoupon = yes (Thanks to ircary)
|
129 |
|
130 |
= 1.0 =
|
131 |
* First version ever!
|
132 |
+
== Upgrade Notice ==
|
133 |
+
|
134 |
+
= 2.0.0 =
|
135 |
+
New name, extended functionality!
|
136 |
+
Additional features are added to the coupon:
|
137 |
+
Restrict by shipping method, restrict by payment method, restrict by a combination of products.
|
138 |
+
|
139 |
|
woocommerce-jos-autocoupon.php
CHANGED
@@ -1,20 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Plugin Name: WooCommerce
|
4 |
* Plugin URI: http://wordpress.org/plugins/woocommerce-auto-added-coupons
|
5 |
-
* Description:
|
6 |
-
* Version:
|
7 |
* Author: Jos Koenis
|
8 |
* License: GPL2
|
9 |
*/
|
10 |
|
11 |
/*
|
12 |
Change history:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
1.1.5:
|
14 |
- FIX: Cart total discount amount showing wrong discount value in newer WooCommerce versions (tax)
|
15 |
- Performance: get_all_auto_coupons select only where meta woocommerce_jos_autocoupon = yes
|
16 |
1.1.4:
|
17 |
- Translation support through .mo / .po files
|
|
|
18 |
1.1.3.1:
|
19 |
- FIX: Apply auto coupon if discount is 0.00 and free shipping is ticked
|
20 |
1.1.3:
|
@@ -35,274 +43,21 @@
|
|
35 |
|
36 |
defined('ABSPATH') or die();
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
private $meta_key = 'woocommerce-jos-autocoupon';
|
41 |
-
|
42 |
-
private $_autocoupon_codes = null;
|
43 |
-
|
44 |
-
public function __construct() {
|
45 |
-
add_action('init', array( &$this, 'controller_init' ));
|
46 |
-
}
|
47 |
-
|
48 |
-
public function controller_init() {
|
49 |
-
if ( ! class_exists('WC_Coupon') ) {
|
50 |
-
return;
|
51 |
-
}
|
52 |
-
|
53 |
-
load_plugin_textdomain('woocommerce-jos-autocoupon', false, basename(dirname(__FILE__)) . '/languages/' );
|
54 |
-
|
55 |
-
//Admin hooks
|
56 |
-
add_action( 'woocommerce_coupon_options_usage_restriction', array( $this, 'coupon_options' ), 10, 0 );
|
57 |
-
add_action( 'woocommerce_process_shop_coupon_meta', array( $this, 'process_shop_coupon_meta' ), 10, 2 );
|
58 |
-
|
59 |
-
//Frontend hooks
|
60 |
-
add_action( 'woocommerce_check_cart_items', array( &$this, 'update_matched_autocoupons' ) , 0 ); //Remove coupon before WC does it and shows a message
|
61 |
-
add_filter('woocommerce_cart_totals_coupon_label', array( &$this, 'coupon_label' ), 10, 2 );
|
62 |
-
add_filter('woocommerce_cart_totals_coupon_html', array( &$this, 'coupon_html' ), 10, 2 );
|
63 |
-
|
64 |
-
add_action( 'wp_loaded', array( &$this, 'coupon_by_url' )); //Coupon through url
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
/* ADMIN HOOKS */
|
69 |
-
|
70 |
-
public function coupon_options() {
|
71 |
-
woocommerce_wp_checkbox( array(
|
72 |
-
'id' => $this->meta_key,
|
73 |
-
'label' => __( 'Auto coupon', 'woocommerce-jos-autocoupon' ),
|
74 |
-
'description' => __( "Automatically add the coupon to the cart if the restrictions are met. Please enter a description when you check this box, the description will be shown in the customers cart if the coupon is applied. (JOS - Woocommerce auto added coupons plugin).", 'woocommerce-jos-autocoupon' )
|
75 |
-
) );
|
76 |
-
}
|
77 |
-
|
78 |
-
public function process_shop_coupon_meta( $post_id, $post ) {
|
79 |
-
$autocoupon = isset( $_POST[$this->meta_key] ) ? 'yes' : 'no';
|
80 |
-
update_post_meta( $post_id, $this->meta_key, $autocoupon );
|
81 |
-
}
|
82 |
-
|
83 |
-
/* FRONTEND HOOKS */
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Add coupon through url
|
87 |
-
*/
|
88 |
-
public function coupon_by_url() {
|
89 |
-
if (isset($_GET['apply_coupon'])) {
|
90 |
-
$split = explode( ",", $_GET['apply_coupon'] );
|
91 |
-
|
92 |
-
global $woocommerce;
|
93 |
-
foreach ( $split as $coupon_code ) {
|
94 |
-
$woocommerce->cart->add_discount( $coupon_code );
|
95 |
-
}
|
96 |
-
}
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Overwrite the html created by wc_cart_totals_coupon_label() so a descriptive text will be shown for the discount.
|
101 |
-
* @param string $originaltext The default text created by wc_cart_totals_coupon_label()
|
102 |
-
* @param WC_Coupon $coupon The coupon data
|
103 |
-
* @return string The overwritten text
|
104 |
-
*/
|
105 |
-
function coupon_label( $originaltext, $coupon ) {
|
106 |
-
|
107 |
-
if ( $this->is_auto_coupon($coupon) ) {
|
108 |
-
|
109 |
-
return $this->coupon_excerpt($coupon); //__($this->autocoupons[$coupon->code], 'woocommerce-jos-autocoupon');
|
110 |
-
} else {
|
111 |
-
return $originaltext;
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Overwrite the html created by wc_cart_totals_coupon_html(). This function is required to remove the "Remove" link.
|
117 |
-
* @param string $originaltext The html created by wc_cart_totals_coupon_html()
|
118 |
-
* @param WC_Coupon $coupon The coupon data
|
119 |
-
* @return string The overwritten html
|
120 |
-
*/
|
121 |
-
function coupon_html( $originaltext, $coupon ) {
|
122 |
-
if ( $this->is_auto_coupon($coupon) ) {
|
123 |
-
$value = array();
|
124 |
-
|
125 |
-
if ( $amount = WC()->cart->get_coupon_discount_amount( $coupon->code, WC()->cart->display_cart_ex_tax ) ) {
|
126 |
-
$discount_html = '-' . wc_price( $amount );
|
127 |
-
} else {
|
128 |
-
$discount_html = '';
|
129 |
-
}
|
130 |
-
|
131 |
-
$value[] = apply_filters( 'woocommerce_coupon_discount_amount_html', $discount_html, $coupon );
|
132 |
-
|
133 |
-
if ( $coupon->enable_free_shipping() ) {
|
134 |
-
$value[] = __( 'Free shipping coupon', 'woocommerce' );
|
135 |
-
}
|
136 |
-
|
137 |
-
return implode(', ', array_filter($value)); //Remove empty array elements
|
138 |
-
} else {
|
139 |
-
return $originaltext;
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Apply matched autocoupons and remove unmatched autocoupons.
|
145 |
-
* @return void
|
146 |
-
*/
|
147 |
-
function update_matched_autocoupons() {
|
148 |
-
global $woocommerce;
|
149 |
-
$this->remove_unmatched_autocoupons();
|
150 |
-
foreach ( $this->get_all_auto_coupons() as $coupon_code ) {
|
151 |
-
if ( ! $woocommerce->cart->has_discount( $coupon_code ) ) {
|
152 |
-
$coupon = new WC_Coupon($coupon_code);
|
153 |
-
if ( $this->coupon_can_be_applied($coupon) ) {
|
154 |
-
$woocommerce->cart->add_discount( $coupon_code );
|
155 |
-
$this->overwrite_success_message( $coupon );
|
156 |
-
}
|
157 |
-
}
|
158 |
-
}
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Test whether the coupon is valid and has a discount > 0
|
163 |
-
* @return bool
|
164 |
-
*/
|
165 |
-
function coupon_can_be_applied($coupon) {
|
166 |
-
global $woocommerce;
|
167 |
-
|
168 |
-
if ( ! $coupon->is_valid() ) {
|
169 |
-
return false;
|
170 |
-
} else if ( $coupon->individual_use == 'yes' && count( $woocommerce->cart->applied_coupons ) != 0 ) {
|
171 |
-
return false;
|
172 |
-
} else {
|
173 |
-
if ( $coupon->enable_free_shipping() ) {
|
174 |
-
return true;
|
175 |
-
}
|
176 |
-
//Test whether discount > 0
|
177 |
-
foreach ( $woocommerce->cart->get_cart() as $cart_item) {
|
178 |
-
if ( $coupon->is_valid_for_cart() || $coupon->is_valid_for_product( $cart_item['data'], $cart_item ) ) {
|
179 |
-
if ( $coupon->get_discount_amount( $cart_item['data']->price, $cart_item ) > 0 ) {
|
180 |
-
return true;
|
181 |
-
}
|
182 |
-
}
|
183 |
-
}
|
184 |
-
}
|
185 |
-
return false;
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Remove unmatched autocoupons. No message will be shown.
|
190 |
-
* NOTE: This function must be called before WooCommerce removes the coupon, to inhibit WooCommerces "coupon not valid"-message!
|
191 |
-
* @return void
|
192 |
-
*/
|
193 |
-
function remove_unmatched_autocoupons() {
|
194 |
-
global $woocommerce;
|
195 |
-
|
196 |
-
foreach ( $this->get_all_auto_coupons() as $coupon_code ) {
|
197 |
-
if ( $woocommerce->cart->has_discount( $coupon_code ) ) {
|
198 |
-
$coupon = new WC_Coupon($coupon_code);
|
199 |
-
if ( ! $this->coupon_can_be_applied($coupon) ) {
|
200 |
-
WC()->cart->remove_coupon( $coupon_code );
|
201 |
-
}
|
202 |
-
}
|
203 |
-
}
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Overwrite the default "Coupon added" notice with a more descriptive message.
|
208 |
-
* @param WC_Coupon $coupon The coupon data
|
209 |
-
* @return void
|
210 |
-
*/
|
211 |
-
private function overwrite_success_message( $coupon ) {
|
212 |
-
$succss_msg = $coupon->get_coupon_message( WC_Coupon::WC_COUPON_SUCCESS );
|
213 |
-
|
214 |
-
$new_succss_msg = sprintf(
|
215 |
-
__("Discount applied: %s", 'woocommerce-jos-autocoupon'),
|
216 |
-
__($this->coupon_excerpt($coupon), 'woocommerce-jos-autocoupon')
|
217 |
-
);
|
218 |
-
|
219 |
-
//Compatibility woocommerce-2-1-notice-api
|
220 |
-
if ( function_exists('wc_get_notices') ) {
|
221 |
-
$all_notices = wc_get_notices();
|
222 |
-
$messages = $all_notices['success'];
|
223 |
-
} else {
|
224 |
-
$messages = $woocommerce->messages;
|
225 |
-
}
|
226 |
-
|
227 |
-
$sizeof_messages = sizeof($messages);
|
228 |
-
for( $y=0; $y < $sizeof_messages; $y++ ) {
|
229 |
-
if ( $messages[$y] == $succss_msg ) {
|
230 |
-
if ( isset($all_notices) ) {
|
231 |
-
//unset ( $all_notices['success'][$y] );
|
232 |
-
$all_notices['success'][$y] = $new_succss_msg;
|
233 |
-
WC()->session->set( 'wc_notices', $all_notices );
|
234 |
-
} else {
|
235 |
-
//unset ( $messages[$y] );
|
236 |
-
$messages[$y] = $new_succss_msg;
|
237 |
-
}
|
238 |
-
|
239 |
-
break;
|
240 |
-
}
|
241 |
-
}
|
242 |
-
}
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Check wether the coupon is an "Auto coupon".
|
246 |
-
* @param WC_Coupon $coupon The coupon data
|
247 |
-
* @return bool true if it is an "Auto coupon"
|
248 |
-
*/
|
249 |
-
private function is_auto_coupon($coupon) {
|
250 |
-
return get_post_meta( $coupon->id, $this->meta_key, true ) == 'yes';
|
251 |
-
}
|
252 |
-
|
253 |
-
/**
|
254 |
-
* Get the coupon excerpt (description)
|
255 |
-
* @param WC_Coupon $coupon The coupon data
|
256 |
-
* @return string The excerpt (translated)
|
257 |
-
*/
|
258 |
-
private function coupon_excerpt($coupon) {
|
259 |
-
$my_post = get_post($coupon->id);
|
260 |
-
return __($my_post->post_excerpt, 'woocommerce-jos-autocoupon');
|
261 |
-
}
|
262 |
-
|
263 |
-
/**
|
264 |
-
* Get a list of all auto coupon codes
|
265 |
-
* @return array All auto coupon codes
|
266 |
-
*/
|
267 |
-
private function get_all_auto_coupons() {
|
268 |
-
|
269 |
-
if ( !is_array($this->_autocoupon_codes) ) {
|
270 |
-
$this->_autocoupon_codes = array();
|
271 |
-
|
272 |
-
$query_args = array(
|
273 |
-
'posts_per_page' => -1,
|
274 |
-
'post_type' => 'shop_coupon',
|
275 |
-
'post_status' => 'publish',
|
276 |
-
'orderby' => 'title',
|
277 |
-
'meta_query' => array(
|
278 |
-
array(
|
279 |
-
'key' => 'woocommerce-jos-autocoupon',
|
280 |
-
'value' => 'yes',
|
281 |
-
'compare' => '=',
|
282 |
-
),
|
283 |
-
)
|
284 |
-
);
|
285 |
-
|
286 |
-
$query = new WP_Query($query_args);
|
287 |
-
foreach ($query->posts as $post) {
|
288 |
-
$coupon = new WC_Coupon($post->post_title);
|
289 |
-
if ( $this->is_auto_coupon($coupon) ) {
|
290 |
-
$this->_autocoupon_codes[] = $post->post_title;
|
291 |
-
}
|
292 |
-
}
|
293 |
-
}
|
294 |
-
return $this->_autocoupon_codes;
|
295 |
-
}
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
}
|
300 |
|
301 |
/**
|
302 |
* Create the plugin if WooCommerce is active
|
303 |
**/
|
304 |
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
|
305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
}
|
307 |
|
308 |
/**
|
@@ -311,9 +66,43 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
|
|
311 |
if ( ! function_exists( 'woocommerce_jos_autocoupon_plugin_meta' ) ) {
|
312 |
function woocommerce_jos_autocoupon_plugin_meta( $links, $file ) {
|
313 |
if ( strpos( $file, 'woocommerce-jos-autocoupon.php' ) !== false ) {
|
314 |
-
$links = array_merge( $links, array( '<a href="
|
315 |
}
|
316 |
return $links;
|
317 |
}
|
318 |
add_filter( 'plugin_row_meta', 'woocommerce_jos_autocoupon_plugin_meta', 10, 2 );
|
319 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Plugin Name: WooCommerce Extended Coupon Features
|
4 |
* Plugin URI: http://wordpress.org/plugins/woocommerce-auto-added-coupons
|
5 |
+
* Description: Additional functionality for WooCommerce Coupons: Apply certain coupons automatically, allow applying coupons via an url, etc...
|
6 |
+
* Version: 2.0.0
|
7 |
* Author: Jos Koenis
|
8 |
* License: GPL2
|
9 |
*/
|
10 |
|
11 |
/*
|
12 |
Change history:
|
13 |
+
2.0.0:
|
14 |
+
- RENAME: Renamed plugin from "WooCommerce auto added coupons" to "WooCommerce Extended Coupon Features"
|
15 |
+
- FEATURE: Restrict coupons by payment method
|
16 |
+
- FEATURE: Restrict coupons by shipping method
|
17 |
+
- FEATURE: Use AND-operator for the selected products (default is OR)
|
18 |
+
- FIX: Validate email restrictions for auto coupons
|
19 |
+
- Norwegian translation added (Thanks to Anders Zorensen)
|
20 |
1.1.5:
|
21 |
- FIX: Cart total discount amount showing wrong discount value in newer WooCommerce versions (tax)
|
22 |
- Performance: get_all_auto_coupons select only where meta woocommerce_jos_autocoupon = yes
|
23 |
1.1.4:
|
24 |
- Translation support through .mo / .po files
|
25 |
+
- Included translations: Dutch, German, Spanish (Thanks to stephan.sperling for the german translation)
|
26 |
1.1.3.1:
|
27 |
- FIX: Apply auto coupon if discount is 0.00 and free shipping is ticked
|
28 |
1.1.3:
|
43 |
|
44 |
defined('ABSPATH') or die();
|
45 |
|
46 |
+
require_once( 'includes/wjecf-autocoupon.php' );
|
47 |
+
require_once( 'includes/wjecf-coupon-extensions.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
/**
|
50 |
* Create the plugin if WooCommerce is active
|
51 |
**/
|
52 |
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
|
53 |
+
|
54 |
+
add_action('plugins_loaded', function() {
|
55 |
+
load_plugin_textdomain('woocommerce-jos-autocoupon', false, basename(dirname(__FILE__)) . '/languages/' );
|
56 |
+
} );
|
57 |
+
|
58 |
+
$wjce_extended_coupon_features = new WC_Jos_Extended_Coupon_Features_Controller();
|
59 |
+
$wjce_autocoupon = new WC_Jos_AutoCoupon_Controller();
|
60 |
+
|
61 |
}
|
62 |
|
63 |
/**
|
66 |
if ( ! function_exists( 'woocommerce_jos_autocoupon_plugin_meta' ) ) {
|
67 |
function woocommerce_jos_autocoupon_plugin_meta( $links, $file ) {
|
68 |
if ( strpos( $file, 'woocommerce-jos-autocoupon.php' ) !== false ) {
|
69 |
+
$links = array_merge( $links, array( '<a href="' . WC_Jos_Extended_Coupon_Features_Controller::get_donate_url() . '" title="Support the development" target="_blank">Donate</a>' ) );
|
70 |
}
|
71 |
return $links;
|
72 |
}
|
73 |
add_filter( 'plugin_row_meta', 'woocommerce_jos_autocoupon_plugin_meta', 10, 2 );
|
74 |
}
|
75 |
+
|
76 |
+
|
77 |
+
|
78 |
+
// =========================================================================================================
|
79 |
+
// Some snippets that might be useful
|
80 |
+
// =========================================================================================================
|
81 |
+
|
82 |
+
/* // HINT: Use this snippet in your theme if you use coupons with restricted emails and AJAX enabled one-page-checkout.
|
83 |
+
|
84 |
+
//Update the cart preview when the billing email is changed by the customer
|
85 |
+
add_filter( 'woocommerce_checkout_fields', function( $checkout_fields ) {
|
86 |
+
$checkout_fields['billing']['billing_email']['class'][] = 'update_totals_on_change';
|
87 |
+
return $checkout_fields;
|
88 |
+
} );
|
89 |
+
|
90 |
+
// */
|
91 |
+
|
92 |
+
|
93 |
+
/* // HINT: Use this snippet in your theme if you want to update cart preview after changing payment method.
|
94 |
+
//Even better: In your theme add class "update_totals_on_change" to the container that contains the payment method radio buttons.
|
95 |
+
//Do this by overriding woocommerce/templates/checkout/payment.php
|
96 |
+
|
97 |
+
//Update the cart preview when payment method is changed by the customer
|
98 |
+
add_action( 'woocommerce_review_order_after_submit' , function () {
|
99 |
+
?><script type="text/javascript">
|
100 |
+
jQuery(document).ready(function($){
|
101 |
+
$(document.body).on('change', 'input[name="payment_method"]', function() {
|
102 |
+
$('body').trigger('update_checkout');
|
103 |
+
$.ajax( $fragment_refresh );
|
104 |
+
});
|
105 |
+
});
|
106 |
+
</script><?php
|
107 |
+
} );
|
108 |
+
// */
|