Version Description
- add separated function to get the available variations
- Added support for out of stock for Sober theme
Download this release
Release Info
Developer | themealien |
Plugin | Variation Swatches for WooCommerce |
Version | 2.0.2 |
Comparing to | |
See all releases |
Code changes from version 2.0.1 to 2.0.2
- assets/js/frontend.js +6 -4
- includes/class-frontend.php +19 -4
- readme.txt +5 -1
- variation-swatches-for-woocommerce.php +2 -2
assets/js/frontend.js
CHANGED
@@ -10,6 +10,8 @@
|
|
10 |
|
11 |
$form
|
12 |
.addClass( 'swatches-support' )
|
|
|
|
|
13 |
.on( 'click', '.swatch', function ( e ) {
|
14 |
e.preventDefault();
|
15 |
|
@@ -54,9 +56,9 @@
|
|
54 |
} )
|
55 |
.on( 'woocommerce_update_variation_values', function() {
|
56 |
setTimeout( function() {
|
57 |
-
$form.find( '
|
58 |
-
var $
|
59 |
-
$options = $
|
60 |
$selected = $options.filter( ':selected' ),
|
61 |
values = [];
|
62 |
|
@@ -66,7 +68,7 @@
|
|
66 |
}
|
67 |
} );
|
68 |
|
69 |
-
$
|
70 |
var $swatch = $( this ),
|
71 |
value = $swatch.attr( 'data-value' );
|
72 |
|
10 |
|
11 |
$form
|
12 |
.addClass( 'swatches-support' )
|
13 |
+
.data("product_variations", $form.find(".tawcvs-available-product-variation").data("product_variations"))
|
14 |
+
.trigger('reload_product_variations')
|
15 |
.on( 'click', '.swatch', function ( e ) {
|
16 |
e.preventDefault();
|
17 |
|
56 |
} )
|
57 |
.on( 'woocommerce_update_variation_values', function() {
|
58 |
setTimeout( function() {
|
59 |
+
$form.find( '.variation-selector' ).each( function() {
|
60 |
+
var $variationSelector = $( this ),
|
61 |
+
$options = $variationSelector.find( 'select' ).find( 'option' ),
|
62 |
$selected = $options.filter( ':selected' ),
|
63 |
values = [];
|
64 |
|
68 |
}
|
69 |
} );
|
70 |
|
71 |
+
$variationSelector.closest('.value').find( '.swatch' ).each( function() {
|
72 |
var $swatch = $( this ),
|
73 |
value = $swatch.attr( 'data-value' );
|
74 |
|
includes/class-frontend.php
CHANGED
@@ -31,6 +31,7 @@ class TA_WC_Variation_Swatches_Frontend {
|
|
31 |
*/
|
32 |
public function __construct() {
|
33 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
|
|
34 |
|
35 |
add_filter( 'woocommerce_dropdown_variation_attribute_options_html', array(
|
36 |
$this,
|
@@ -65,6 +66,22 @@ class TA_WC_Variation_Swatches_Frontend {
|
|
65 |
add_action( 'wp_head', array( $this, 'apply_custom_design_styles' ) );
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
/**
|
69 |
* Enqueue scripts and stylesheets
|
70 |
*/
|
@@ -369,10 +386,8 @@ class TA_WC_Variation_Swatches_Frontend {
|
|
369 |
|
370 |
/*tooltip*/
|
371 |
.tawcvs-swatches .swatch .swatch__tooltip {
|
372 |
-
<?php if(isset($this->toolTipDesign['item-font']) && $this->toolTipDesign['item-font']):?>
|
373 |
-
|
374 |
-
<?php endif;?>
|
375 |
-
width: <?php echo isset($this->toolTipDesign['width']) ? $this->toolTipDesign['width'] . 'px' : 'auto' ?>;
|
376 |
max-width: <?php echo isset($this->toolTipDesign['max-width']) ? $this->toolTipDesign['max-width'] .'px' : '100%' ?>;
|
377 |
line-height: <?php echo isset($this->toolTipDesign['line-height']) ?: 'unset'; ?>;
|
378 |
}
|
31 |
*/
|
32 |
public function __construct() {
|
33 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
34 |
+
add_action( 'woocommerce_before_variations_form', array( $this, 'get_available_variation' ) );
|
35 |
|
36 |
add_filter( 'woocommerce_dropdown_variation_attribute_options_html', array(
|
37 |
$this,
|
66 |
add_action( 'wp_head', array( $this, 'apply_custom_design_styles' ) );
|
67 |
}
|
68 |
|
69 |
+
/**
|
70 |
+
* Getting all available variations to a hidden elements
|
71 |
+
*/
|
72 |
+
public function get_available_variation() {
|
73 |
+
global $product;
|
74 |
+
if ( $product instanceof WC_Product_Variable ) {
|
75 |
+
$variations_json = wp_json_encode( $product->get_available_variations() );
|
76 |
+
$variations_attr = function_exists( 'wc_esc_json' ) ? wc_esc_json( $variations_json ) : _wp_specialchars( $variations_json, ENT_QUOTES, 'UTF-8', true );
|
77 |
+
if ( ! empty( $variations_attr ) ) {
|
78 |
+
?>
|
79 |
+
<div class="tawcvs-placeholder-element hidden tawcvs-available-product-variation"
|
80 |
+
data-product_variations="<?php echo $variations_attr; ?>"></div>
|
81 |
+
<?php }
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
/**
|
86 |
* Enqueue scripts and stylesheets
|
87 |
*/
|
386 |
|
387 |
/*tooltip*/
|
388 |
.tawcvs-swatches .swatch .swatch__tooltip {
|
389 |
+
<?php if(isset($this->toolTipDesign['item-font']) && $this->toolTipDesign['item-font']):?> font-size: <?php echo isset($this->toolTipDesign['text-font-size']) ? $this->toolTipDesign['text-font-size'] : '14'; echo isset($this->toolTipDesign['item-font-size-type']) ? $this->toolTipDesign['item-font-size-type'] : 'px'; ?>;
|
390 |
+
<?php endif;?> width: <?php echo isset($this->toolTipDesign['width']) ? $this->toolTipDesign['width'] . 'px' : 'auto' ?>;
|
|
|
|
|
391 |
max-width: <?php echo isset($this->toolTipDesign['max-width']) ? $this->toolTipDesign['max-width'] .'px' : '100%' ?>;
|
392 |
line-height: <?php echo isset($this->toolTipDesign['line-height']) ?: 'unset'; ?>;
|
393 |
}
|
readme.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
=== Variation Swatches for WooCommerce ===
|
2 |
-
Contributors: variationswatches, themealien, zgani,
|
3 |
Tags: variation swatches, woocommerce, product attribute, product color, product size, variable products
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 5.8
|
@@ -103,6 +103,10 @@ Yes, it will work with any theme, but may require some styling to make it match
|
|
103 |
7. Add new attribute color when edit a product
|
104 |
|
105 |
== Changelog ==
|
|
|
|
|
|
|
|
|
106 |
= 2.0.1 =
|
107 |
* Make the Circle Shape as default option
|
108 |
* Show the global attribute image first, then show the default image if empty
|
1 |
=== Variation Swatches for WooCommerce ===
|
2 |
+
Contributors: variationswatches, themealien, zgani, mehbubrashid, minhnguyen25
|
3 |
Tags: variation swatches, woocommerce, product attribute, product color, product size, variable products
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 5.8
|
103 |
7. Add new attribute color when edit a product
|
104 |
|
105 |
== Changelog ==
|
106 |
+
= 2.0.2 =
|
107 |
+
* add separated function to get the available variations
|
108 |
+
* Added support for out of stock for Sober theme
|
109 |
+
|
110 |
= 2.0.1 =
|
111 |
* Make the Circle Shape as default option
|
112 |
* Show the global attribute image first, then show the default image if empty
|
variation-swatches-for-woocommerce.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Variation Swatches for WooCommerce
|
4 |
* Plugin URI: https://woosuite.com/plugins/woocommerce-variation-swatches/
|
5 |
* Description: Creates variation swatches for WooCommerce, converts your variation dropdown into color, label, or photo swatches with ease, The original Variation Swatches for WooCommerce.
|
6 |
-
* Version: 2.0.
|
7 |
* Author: Woosuite
|
8 |
* Author URI: https://woosuite.com/
|
9 |
* Requires at least: 4.5
|
@@ -27,7 +27,7 @@ if ( ! defined( 'TAWC_VS_PLUGIN_FILE' ) ) {
|
|
27 |
}
|
28 |
|
29 |
if ( ! defined( 'WCVS_PLUGIN_VERSION' ) ) {
|
30 |
-
define( 'WCVS_PLUGIN_VERSION', '2.0.
|
31 |
}
|
32 |
|
33 |
if ( ! defined( 'WCVS_PLUGIN_URL' ) ) {
|
3 |
* Plugin Name: Variation Swatches for WooCommerce
|
4 |
* Plugin URI: https://woosuite.com/plugins/woocommerce-variation-swatches/
|
5 |
* Description: Creates variation swatches for WooCommerce, converts your variation dropdown into color, label, or photo swatches with ease, The original Variation Swatches for WooCommerce.
|
6 |
+
* Version: 2.0.2
|
7 |
* Author: Woosuite
|
8 |
* Author URI: https://woosuite.com/
|
9 |
* Requires at least: 4.5
|
27 |
}
|
28 |
|
29 |
if ( ! defined( 'WCVS_PLUGIN_VERSION' ) ) {
|
30 |
+
define( 'WCVS_PLUGIN_VERSION', '2.0.2' );
|
31 |
}
|
32 |
|
33 |
if ( ! defined( 'WCVS_PLUGIN_URL' ) ) {
|