Booster for WooCommerce - Version 2.0.8

Version Description

  • 30/12/2014 =
  • Dev - PRODUCTS - SKUs - Variable Products Variations SKUs handling options added.
Download this release

Release Info

Developer algoritmika
Plugin Icon 128x128 Booster for WooCommerce
Version 2.0.8
Comparing to
See all releases

Code changes from version 2.0.7 to 2.0.8

Files changed (3) hide show
  1. includes/class-wcj-sku.php +85 -13
  2. readme.txt +7 -11
  3. woocommerce-jetpack.php +1 -1
includes/class-wcj-sku.php CHANGED
@@ -37,17 +37,61 @@ class WCJ_SKU {
37
  }
38
 
39
  /**
40
- * set_sku.
41
  */
42
- public function set_sku( $product_id ) {
43
- $the_sku = sprintf( '%s%0' . get_option( 'wcj_sku_minimum_number_length', 0 ) . 'd%s', get_option( 'wcj_sku_prefix', '' ), $product_id, apply_filters( 'wcj_get_option_filter', '', get_option( 'wcj_sku_suffix', '' ) ) );
44
- update_post_meta( $product_id, '_' . 'sku', $the_sku );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
 
47
  /**
48
  * set_sku.
49
  */
50
- public function set_all_sku() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  $args = array(
52
  'post_type' => 'product',
53
  'post_status' => 'any',
@@ -55,7 +99,8 @@ class WCJ_SKU {
55
  );
56
  $loop = new WP_Query( $args );
57
  while ( $loop->have_posts() ) : $loop->the_post();
58
- $this->set_sku( $loop->post->ID );
 
59
  endwhile;
60
  }
61
 
@@ -66,7 +111,7 @@ class WCJ_SKU {
66
  if ( 'product' !== $post->type )
67
  return;
68
  if ( false === $update ) {
69
- $this->set_sku( $post_ID );
70
  }
71
  }
72
 
@@ -86,17 +131,29 @@ class WCJ_SKU {
86
  */
87
  public function create_sku_tool() {
88
  $result_message = '';
89
- if ( isset( $_POST['set_sku'] ) ) {
90
- $this->set_all_sku();
 
 
 
 
 
 
 
 
 
 
91
  $result_message = '<p><div class="updated"><p><strong>' . __( 'SKUs generated and set successfully!', 'woocommerce-jetpack' ) . '</strong></p></div></p>';
92
  }
93
  ?><div>
94
  <h2><?php echo __( 'WooCommerce Jetpack - Autogenerate SKUs', 'woocommerce-jetpack' ); ?></h2>
95
  <p><?php echo __( 'The tool generates and sets product SKUs.', 'woocommerce-jetpack' ); ?></p>
96
- <?php echo $result_message; ?>
97
- <form method="post" action="">
98
- <input class="button-primary" type="submit" name="set_sku" value="Set SKUs">
99
- </form>
 
 
100
  </div><?php
101
  }
102
 
@@ -169,6 +226,21 @@ class WCJ_SKU {
169
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
170
  'custom_attributes'
171
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  ),
173
 
174
  array(
37
  }
38
 
39
  /**
40
+ * set_sku_with_variable.
41
  */
42
+ public function set_sku_with_variable( $product_id, $is_preview ) {
43
+ $this->set_sku( $product_id, $product_id, '', $is_preview );
44
+ // Handling variable products
45
+ $variation_handling = apply_filters( 'wcj_get_option_filter', 'as_variable', get_option( 'wcj_sku_variations_handling', 'as_variable' ) );
46
+ $product = wc_get_product( $product_id );
47
+ if ( $product->is_type( 'variable' ) ) {
48
+
49
+ $variations = $product->get_available_variations();
50
+
51
+ if ( 'as_variable' === $variation_handling ) {
52
+ foreach( $variations as $variation )
53
+ $this->set_sku( $variation['variation_id'], $product_id, '', $is_preview );
54
+ }
55
+ else if ( 'as_variation' === $variation_handling ) {
56
+ foreach( $variations as $variation )
57
+ $this->set_sku( $variation['variation_id'], $variation['variation_id'], '', $is_preview );
58
+ }
59
+ else if ( 'as_variable_with_suffix' === $variation_handling ) {
60
+ $variation_suffixes = 'abcdefghijklmnopqrstuvwxyz';
61
+ $abc = 0;
62
+ foreach( $variations as $variation ) {
63
+ $this->set_sku( $variation['variation_id'], $product_id, $variation_suffixes[ $abc++ ], $is_preview );
64
+ if ( 26 == $abc )
65
+ $abc = 0;
66
+ }
67
+ }
68
+ }
69
  }
70
 
71
  /**
72
  * set_sku.
73
  */
74
+ public function set_sku( $product_id, $sku_number, $variation_suffix, $is_preview ) {
75
+ $the_sku = sprintf( '%s%0' . get_option( 'wcj_sku_minimum_number_length', 0 ) . 'd%s%s',
76
+ get_option( 'wcj_sku_prefix', '' ),
77
+ $sku_number,
78
+ apply_filters( 'wcj_get_option_filter', '', get_option( 'wcj_sku_suffix', '' ) ),
79
+ $variation_suffix );
80
+
81
+ if ( $is_preview ) {
82
+ echo '<tr>' .
83
+ '<td>' . get_the_title( $product_id ) . '</td>' .
84
+ '<td>' . $the_sku . '</td>' .
85
+ '</tr>';
86
+ }
87
+ else
88
+ update_post_meta( $product_id, '_' . 'sku', $the_sku );
89
+ }
90
+
91
+ /**
92
+ * set_all_sku.
93
+ */
94
+ public function set_all_sku( $is_preview ) {
95
  $args = array(
96
  'post_type' => 'product',
97
  'post_status' => 'any',
99
  );
100
  $loop = new WP_Query( $args );
101
  while ( $loop->have_posts() ) : $loop->the_post();
102
+ $this->set_sku_with_variable( $loop->post->ID, $is_preview );
103
+
104
  endwhile;
105
  }
106
 
111
  if ( 'product' !== $post->type )
112
  return;
113
  if ( false === $update ) {
114
+ $this->set_sku_with_variable( $post_ID, false );
115
  }
116
  }
117
 
131
  */
132
  public function create_sku_tool() {
133
  $result_message = '';
134
+ if ( isset( $_POST['set_sku'] ) || isset( $_POST['preview_sku'] ) ) {
135
+ $is_preview = ( isset( $_POST['preview_sku'] ) ) ? true : false;
136
+
137
+ $preview_html = '<table class="widefat" style="width:50%; min-width: 300px;">';
138
+ $preview_html .= '<tr>' .
139
+ '<th>' . __( 'Product', 'woocommerce-jetpack' ) . '</th>' .
140
+ '<th>' . __( 'SKU', 'woocommerce-jetpack' ) . '</th>' .
141
+ '</tr>';
142
+ ob_start();
143
+ $this->set_all_sku( $is_preview );
144
+ $preview_html .= ob_get_clean();
145
+ $preview_html .= '<table>';
146
  $result_message = '<p><div class="updated"><p><strong>' . __( 'SKUs generated and set successfully!', 'woocommerce-jetpack' ) . '</strong></p></div></p>';
147
  }
148
  ?><div>
149
  <h2><?php echo __( 'WooCommerce Jetpack - Autogenerate SKUs', 'woocommerce-jetpack' ); ?></h2>
150
  <p><?php echo __( 'The tool generates and sets product SKUs.', 'woocommerce-jetpack' ); ?></p>
151
+ <?php if ( ! $is_preview ) echo $result_message; ?>
152
+ <p><form method="post" action="">
153
+ <input class="button-primary" type="submit" name="preview_sku" id="preview_sku" value="Preview SKUs">
154
+ <input class="button-primary" type="submit" name="set_sku" value="Set SKUs">
155
+ </form></p>
156
+ <?php if ( $is_preview ) echo $preview_html; ?>
157
  </div><?php
158
  }
159
 
226
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
227
  'custom_attributes'
228
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
229
+ ),
230
+
231
+ array(
232
+ 'title' => __( 'Variable Products Variations', 'woocommerce-jetpack' ),
233
+ 'id' => 'wcj_sku_variations_handling',
234
+ 'default' => 'as_variable',
235
+ 'type' => 'select',
236
+ 'options' => array(
237
+ 'as_variable' => __( 'SKU same as parent\'s product', 'woocommerce-jetpack' ),
238
+ 'as_variation' => __( 'Generate different SKU for each variation', 'woocommerce-jetpack' ),
239
+ 'as_variable_with_suffix' => __( 'SKU same as parent\'s product + variation suffix', 'woocommerce-jetpack' ),
240
+ ),
241
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
242
+ 'custom_attributes'
243
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
244
  ),
245
 
246
  array(
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://algoritmika.com/donate/
4
  Tags: woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,email pdf invoice,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price,custom css,hide categories count,hide subcategories count,hide category count,hide subcategory count,display total sales,custom product tabs,remove product tab,payment gateway fee,
5
  Requires at least: 3.9.1
6
  Tested up to: 4.1
7
- Stable tag: 2.0.7
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -31,10 +31,12 @@ WooCommerce Jetpack is a WordPress plugin that supercharges your site with aweso
31
  * Product Info - Add more info to product on category or single pages. Change related products number.
32
  * Product Tabs - Add custom product tabs - globally, per category or per product. Customize or completely remove WooCommerce default product tabs.
33
  * Cart - Add "Empty Cart" button to cart page, automatically add product to cart on visit.
34
- * Add to Cart - Change text for add to cart buttons for each product type. Display "Product already in cart" instead of "Add to cart" button. Redirect add to cart button to any url (e.g. checkout page).
35
  * Old Slugs - Remove old product slugs.
36
  * Bulk Price Converter tool.
37
  * Prices and Currencies by Country.
 
 
38
  * Another custom CSS tool, if you need one.
39
 
40
  = Feedback =
@@ -66,6 +68,9 @@ To unlock all WooCommerce Jetpack features, please install additional <a href="h
66
 
67
  == Changelog ==
68
 
 
 
 
69
  = 2.0.7 - 28/12/2014 =
70
  * Dev - PRODUCTS - **Bulk Price Coverter** - Initial module release.
71
  * Dev - CHECKOUT - **Custom Checkout Fields** - Option to add custom checkout fields to emails, added.
@@ -391,14 +396,5 @@ To unlock all WooCommerce Jetpack features, please install additional <a href="h
391
 
392
  == Upgrade Notice ==
393
 
394
- = 1.7.7 =
395
- Bug in **Custom Price Labels** feature causing setting checkboxes back to *on*, fixed. Upgrade immediately.
396
-
397
- = 1.7.6 =
398
- Bug in **Custom Price Labels** feature causing setting all product's checkbox labels to *off*, fixed. Upgrade immediately.
399
-
400
- = 1.7.1 =
401
- Bug causing "PHP Parse error" (reported on servers running PHP 5.3) fixed. Upgrade immediately.
402
-
403
  = 1.0.0 =
404
  This is the first release of the plugin.
4
  Tags: woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,email pdf invoice,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price,custom css,hide categories count,hide subcategories count,hide category count,hide subcategory count,display total sales,custom product tabs,remove product tab,payment gateway fee,
5
  Requires at least: 3.9.1
6
  Tested up to: 4.1
7
+ Stable tag: 2.0.8
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
31
  * Product Info - Add more info to product on category or single pages. Change related products number.
32
  * Product Tabs - Add custom product tabs - globally, per category or per product. Customize or completely remove WooCommerce default product tabs.
33
  * Cart - Add "Empty Cart" button to cart page, automatically add product to cart on visit.
34
+ * Add to Cart - Change text for add to cart buttons for each product type, on per category or per product basis. Display "Product already in cart" instead of "Add to cart" button. Redirect add to cart button to any url (e.g. checkout page).
35
  * Old Slugs - Remove old product slugs.
36
  * Bulk Price Converter tool.
37
  * Prices and Currencies by Country.
38
+ * Bulk SKUs generator tool.
39
+ * Different Currency for External Products.
40
  * Another custom CSS tool, if you need one.
41
 
42
  = Feedback =
68
 
69
  == Changelog ==
70
 
71
+ = 2.0.8 - 30/12/2014 =
72
+ * Dev - PRODUCTS - **SKUs** - *Variable Products Variations SKUs* handling options added.
73
+
74
  = 2.0.7 - 28/12/2014 =
75
  * Dev - PRODUCTS - **Bulk Price Coverter** - Initial module release.
76
  * Dev - CHECKOUT - **Custom Checkout Fields** - Option to add custom checkout fields to emails, added.
396
 
397
  == Upgrade Notice ==
398
 
 
 
 
 
 
 
 
 
 
399
  = 1.0.0 =
400
  This is the first release of the plugin.
woocommerce-jetpack.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WooCommerce Jetpack
4
  Plugin URI: http://woojetpack.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
- Version: 2.0.7
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2014 Algoritmika Ltd.
3
  Plugin Name: WooCommerce Jetpack
4
  Plugin URI: http://woojetpack.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
+ Version: 2.0.8
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2014 Algoritmika Ltd.