Skip to content

Commit

Permalink
Merge pull request #5 from nomasi/master
Browse files Browse the repository at this point in the history
Added fix for selector change event triggering
  • Loading branch information
nomasi authored Feb 5, 2019
2 parents 479653d + a9a01b8 commit 7f51a4c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sizeme-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @wordpress-plugin
* Plugin Name: SizeMe for WooCommerce
* Description: SizeMe is a web store plugin that enables your consumers to input their measurements and get personalised fit recommendations based on actual product data.
* Version: 2.0.2
* Version: 2.0.3
* Author: SizeMe Ltd
* Author URI: https://www.sizeme.com/
* Text Domain: sizeme
Expand Down Expand Up @@ -50,7 +50,7 @@ class WC_SizeMe_for_WooCommerce {
*
* @var string VERSION The plugin version.
*/
const VERSION = '2.0.2';
const VERSION = '2.0.3';

/**
* Minimum WordPress version this plugin works with, used for dependency checks.
Expand Down
15 changes: 13 additions & 2 deletions templates/sizeme-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
if ( $sizeme->is_service_test() ) {
echo 'sizeme_options.debugState = "true";'.PHP_EOL;
}

// UI OPTIONS
$uiOptions = array(
'appendContentTo' => WC_SizeMe_for_WooCommerce::APPEND_CONTENT_TO,
Expand All @@ -56,7 +56,7 @@
'addToCartEvent' => WC_SizeMe_for_WooCommerce::ADD_TO_CART_EVENT,
'lang' => WC_SizeMe_for_WooCommerce::LANG_OVERRIDE
);

foreach ($uiOptions as $key => $value) {
if ( $sizeme->get_ui_option( $value, '' ) ) {
printf('sizeme_options.uiOptions.%s = "%s";'.PHP_EOL, $key, esc_js($sizeme->get_ui_option( $value, '' )));
Expand All @@ -82,6 +82,17 @@
<?php endforeach; ?>
}
};
<?php
//
// Add listener for sizemeChange and trigger local jQuery change event
// Requires that jQuery is defined before this (footer is not ok)
//
// @since 2.0.3
//
$el = '.variations select';
if ( $sizeme->get_ui_option( WC_SizeMe_for_WooCommerce::INVOKE_ELEMENT, '' ) ) $el = $sizeme->get_ui_option( WC_SizeMe_for_WooCommerce::INVOKE_ELEMENT, '' );
echo 'if (window.jQuery) { jQuery(function() { document.querySelector("'.$el.'").addEventListener("sizemeChange", function(e) { jQuery("'.$el.'").trigger("change"); }) } ); }';
?>
//]]>
</script>

Expand Down

0 comments on commit 7f51a4c

Please sign in to comment.