Changeset 2942526
- Timestamp:
- 07/24/2023 12:14:30 PM (3 years ago)
- Location:
- sizeme-for-woocommerce
- Files:
-
- 8 edited
- 3 copied
-
tags/2.3.0 (copied) (copied from sizeme-for-woocommerce/trunk)
-
tags/2.3.0/classes/class-wc-settings-sizeme-for-woocommerce.php (modified) (1 diff)
-
tags/2.3.0/readme.txt (copied) (copied from sizeme-for-woocommerce/trunk/readme.txt) (2 diffs)
-
tags/2.3.0/sizeme-for-woocommerce.php (copied) (copied from sizeme-for-woocommerce/trunk/sizeme-for-woocommerce.php) (7 diffs)
-
tags/2.3.0/templates/sizeme-product.php (modified) (3 diffs)
-
tags/2.3.0/woocommerce/single-product/add-to-cart/variable.php (modified) (4 diffs)
-
trunk/classes/class-wc-settings-sizeme-for-woocommerce.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/sizeme-for-woocommerce.php (modified) (7 diffs)
-
trunk/templates/sizeme-product.php (modified) (3 diffs)
-
trunk/woocommerce/single-product/add-to-cart/variable.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sizeme-for-woocommerce/tags/2.3.0/classes/class-wc-settings-sizeme-for-woocommerce.php
r2293215 r2942526 229 229 ), 230 230 array( 231 'title' => __( 'Match male gender from product name', 'sizeme-for-woocommerce' ), 232 'type' => 'text', 233 'default' => get_option( WC_SizeMe_for_WooCommerce::MATCH_GENDER_FROM_NAME_MALE, '' ), 234 'id' => WC_SizeMe_for_WooCommerce::MATCH_GENDER_FROM_NAME_MALE, 235 ), 236 array( 237 'title' => __( 'Measurement unit', 'sizeme-for-woocommerce' ), 238 'type' => 'radio', 239 'options' => array( 240 'cm' => 'Metric [cm]', 241 'in' => 'Imperial [in]', 242 ), 243 'default' => get_option( WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT, 'cm' ), 244 'id' => WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT, 245 ), 246 array( 247 'title' => __( 'Disallow user from changing measurement unit', 'sizeme-for-woocommerce' ), 248 'type' => 'select', 249 'options' => array( 250 self::ADD_TOGGLER_NO => 'No', // re-using setting 251 self::ADD_TOGGLER_YES => 'Yes', 252 ), 253 'default' => get_option( WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT_CHOICE_DISALLOWED, self::ADD_TOGGLER_NO ), 254 'id' => WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT_CHOICE_DISALLOWED, 255 ), 256 array( 231 257 'title' => __( 'Custom styles', 'sizeme-for-woocommerce' ), 232 258 'type' => 'textarea', -
sizeme-for-woocommerce/tags/2.3.0/readme.txt
r2856957 r2942526 3 3 Tags: sizeme, measurements, sizeguide, size guide, size recommendations 4 4 Requires at least: 3.8 5 Tested up to: 6. 1.16 Stable tag: 2. 2.35 Tested up to: 6.2.2 6 Stable tag: 2.3.0 7 7 Requires PHP: 5.2.4 8 8 WC requires at least: 2.5 9 WC tested up to: 7. 3.09 WC tested up to: 7.9.0 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 83 83 84 84 == Changelog == 85 = 2.3.0 = 86 * Added metric to imperial measurement switch with corresponding options 87 * Added possibility to specify which products are for men to show correct measurement guide videos 88 85 89 = 2.2.3 = 86 90 * Discontinued sending unused email hash -
sizeme-for-woocommerce/tags/2.3.0/sizeme-for-woocommerce.php
r2856957 r2942526 10 10 * Plugin Name: SizeMe for WooCommerce 11 11 * 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. 12 * Version: 2. 2.312 * Version: 2.3.0 13 13 * Author: SizeMe Ltd 14 14 * Author URI: https://www.sizeme.com/ … … 17 17 * 18 18 * WC requires at least: 2.5 19 * WC tested up to: 7. 3.019 * WC tested up to: 7.9.0 20 20 * 21 21 * SizeMe for WooCommerce is free software: you can redistribute it and/or modify … … 54 54 * @var string VERSION The plugin version. 55 55 */ 56 const VERSION = '2. 2.3';56 const VERSION = '2.3.0'; 57 57 58 58 /** … … 238 238 239 239 /** 240 * UI option, m ax recommendation distance, used in settings.240 * UI option, multiselect, size attributes, used to write correct variations to sizeme_product object. 241 241 * 242 242 * @since 2.1.0 243 243 * 244 * @var string MAX_RECOMMENDATION_DISTANCE The key for UI option.244 * @var string SIZE_ATTRIBUTES_KEY The key to store size attributes in wp_options. 245 245 */ 246 246 const SIZE_ATTRIBUTES_KEY = 'sizeme_size_attributes'; 247 247 248 /** 249 * Info related to SizeMe API requests 248 /** 249 * UI option, reg exp string to identify the male gender from product name and/or SKU. 250 * 251 * @since 2.3.0 252 * 253 * @var string MATCH_GENDER_FROM_NAME_MALE Optional string. 254 */ 255 const MATCH_GENDER_FROM_NAME_MALE = 'sizeme_match_gender_from_name_male'; 256 257 /** 258 * UI option, string for default measurement unit: supports "cm" and "in" currently 259 * 260 * @since 2.3.0 261 * 262 * @var string MEASUREMENT_UNIT string. 263 */ 264 const MEASUREMENT_UNIT = 'sizeme_measurement_unit'; 265 266 /** 267 * UI option, select to disallow user from selecting measurement unit 268 * 269 * @since 2.3.0 270 * 271 * @var boolean MEASUREMENT_UNIT_CHOICE_DISALLOWED. 272 */ 273 const MEASUREMENT_UNIT_CHOICE_DISALLOWED = 'sizeme_measurement_unit_choice_disallowed'; 274 275 /** 276 * Info related to SizeMe API requests 250 277 * 251 278 * @since 2.0.0 … … 419 446 420 447 /** 421 * Get the togglerboolean state.422 * 423 * Gets the togglerboolean state from the configuration.448 * Get a boolean state. 449 * 450 * Gets the a boolean state from the configuration. 424 451 * Either 'no' or 'yes' 425 452 * 426 453 * @since 2.0.0 454 * @changed 2.3.0 427 455 * 428 456 * @return string The toggler status as a string. 429 457 */ 430 public function is_toggler_yes( ) {431 return ( get_option( self::ADD_TOGGLER) == 'yes' );458 public function is_toggler_yes( $option ) { 459 return ( get_option( $option ) == 'yes' ); 432 460 } 433 461 … … 961 989 protected function migrate_possible_options() { 962 990 // Check if the sizeme_version option has been set. If it's not present, previous (non-prefixed) option keys are likely to been set. 963 if ( get_option('sizeme_version', NULL) === NULL ) { 991 $current_sizeme_version = get_option('sizeme_version', NULL); 992 if ( $current_sizeme_version === NULL ) { 964 993 // Check if there actually are old options present 965 994 if ( get_option('service_status', NULL) !== NULL ) { … … 985 1014 } 986 1015 1016 /* 1017 // Add new option from version 2.3.0 onward 1018 if (version_compare($current_sizeme_version, '2.3.0', '>=')) { 1019 add_option('new_option_name', 'default_value'); 1020 } 1021 */ 1022 987 1023 return true; 988 1024 } -
sizeme-for-woocommerce/tags/2.3.0/templates/sizeme-product.php
r2293215 r2942526 55 55 'addToCartElement' => WC_SizeMe_for_WooCommerce::ADD_TO_CART_ELEMENT, 56 56 'addToCartEvent' => WC_SizeMe_for_WooCommerce::ADD_TO_CART_EVENT, 57 'lang' => WC_SizeMe_for_WooCommerce::LANG_OVERRIDE 57 'lang' => WC_SizeMe_for_WooCommerce::LANG_OVERRIDE, 58 'measurementUnit' => WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT, 58 59 ); 59 60 … … 65 66 66 67 // TOGGLER 67 if ( $sizeme->is_toggler_yes( ) ) {68 echo 'sizeme_options.uiOptions.toggler = "true";'.PHP_EOL;68 if ( $sizeme->is_toggler_yes( WC_SizeMe_for_WooCommerce::ADD_TOGGLER ) ) { 69 echo 'sizeme_options.uiOptions.toggler = true;'.PHP_EOL; 69 70 } 70 71 … … 76 77 $dist = intval( $sizeme->get_ui_option( WC_SizeMe_for_WooCommerce::MAX_RECOMMENDATION_DISTANCE, '' ) ); 77 78 if ( $dist > 0 ) printf('sizeme_options.uiOptions.maxRecommendationDistance = %d;'.PHP_EOL, $dist ); 79 80 // possible measurementUnitChoiceDisallowed 81 if ( $sizeme->is_toggler_yes( WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT_CHOICE_DISALLOWED ) ) { 82 echo 'sizeme_options.uiOptions.measurementUnitChoiceDisallowed = true;'.PHP_EOL; 83 } 84 85 // possible string 86 $gender_string = trim( $sizeme->get_ui_option( WC_SizeMe_for_WooCommerce::MATCH_GENDER_FROM_NAME_MALE, '' ) ); 87 if ( !empty($gender_string) ) echo 'sizeme_options.uiOptions.matchGenderFromNameMale = "' . htmlspecialchars( $gender_string ) . '";'.PHP_EOL; 88 78 89 ?> 79 90 -
sizeme-for-woocommerce/tags/2.3.0/woocommerce/single-product/add-to-cart/variable.php
r2293215 r2942526 8 8 * will need to copy the new files to your theme to maintain compatibility. 9 9 * 10 * Last checked against WC version 3.4.110 * Last harmonized against WooCommerce\Templates version 6.1.0 11 11 * 12 12 * @see WC_SizeMe_for_WooCommerce::locate_template … … 34 34 */ 35 35 36 if ( ! defined( 'ABSPATH' ) ) { 37 exit; // Exit if accessed directly. 38 } 36 defined( 'ABSPATH' ) || exit; 39 37 40 38 global $product; … … 43 41 44 42 $attribute_keys = array_keys( $attributes ); 43 $variations_json = wp_json_encode( $available_variations ); 44 $variations_attr = function_exists( 'wc_esc_json' ) ? wc_esc_json( $variations_json ) : _wp_specialchars( $variations_json, ENT_QUOTES, 'UTF-8', true ); 45 45 46 46 do_action( 'woocommerce_before_add_to_cart_form' ); ?> 47 47 48 <form class="variations_form cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $product->get_id() ); ?>" data-product_variations="<?php echo htmlspecialchars( wp_json_encode( $available_variations ) ); // WPCS: XSS ok. ?>">48 <form class="variations_form cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $product->get_id() ); ?>" data-product_variations="<?php echo $variations_attr; // WPCS: XSS ok. ?>"> 49 49 <?php do_action( 'woocommerce_before_variations_form' ); ?> 50 50 51 51 <?php if ( empty( $available_variations ) && false !== $available_variations ) : ?> 52 <p class="stock out-of-stock"><?php e sc_attr_e( 'This product is currently out of stock and unavailable.', 'woocommerce'); ?></p>52 <p class="stock out-of-stock"><?php echo esc_html( apply_filters( 'woocommerce_out_of_stock_message', __( 'This product is currently out of stock and unavailable.', 'woocommerce' ) ) ); ?></p> 53 53 <?php else : ?> 54 <table class="variations" cellspacing="0" >54 <table class="variations" cellspacing="0" role="presentation"> 55 55 <tbody> 56 <?php 57 $size_set = false; 58 foreach ( $attributes as $attribute_name => $options ) : 59 $selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? 60 wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : 61 $product->get_variation_default_attribute( $attribute_name ); // Input var okay. 62 63 if ( $sizeme->is_size_attribute( $product, $attribute_name ) && ! $size_set ) { 64 $class = 'sizeme-selection-container'; 65 $size_set = true; 66 } else { 67 $class = ''; 68 } ?> 69 <tr> 70 <td class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo wc_attribute_label( $attribute_name ); // WPCS: XSS ok. ?></label></td> 71 <td class="value<?php echo $class !== '' ? ' ' . esc_attr( $class ) : ''; ?>"> 72 <?php 73 wc_dropdown_variation_attribute_options( array( 74 'options' => $options, 75 'attribute' => $attribute_name, 76 'product' => $product, 77 ) ); 78 echo end( $attribute_keys ) === $attribute_name ? wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '<a class="reset_variations" href="#">' . esc_html__( 'Clear', 'woocommerce' ) . '</a>' ) ) : ''; 79 ?> 80 </td> 81 </tr> 82 <?php endforeach; ?> 56 <?php $size_set = false; ?> 57 <?php foreach ( $attributes as $attribute_name => $options ) : ?> 58 <?php 59 if ( $sizeme->is_size_attribute( $product, $attribute_name ) && ! $size_set ) { 60 $class = 'sizeme-selection-container'; 61 $size_set = true; 62 } else { 63 $class = ''; 64 } 65 ?> 66 <tr> 67 <th class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo wc_attribute_label( $attribute_name ); // WPCS: XSS ok. ?></label></th> 68 <td class="value<?php echo $class !== '' ? ' ' . esc_attr( $class ) : ''; ?>"> 69 <?php 70 wc_dropdown_variation_attribute_options( 71 array( 72 'options' => $options, 73 'attribute' => $attribute_name, 74 'product' => $product, 75 ) 76 ); 77 echo end( $attribute_keys ) === $attribute_name ? wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '<a class="reset_variations" href="#">' . esc_html__( 'Clear', 'woocommerce' ) . '</a>' ) ) : ''; 78 ?> 79 </td> 80 </tr> 81 <?php endforeach; ?> 83 82 </tbody> 84 83 </table> 85 84 86 85 <div class="sizeme-container"></div> 86 87 <?php do_action( 'woocommerce_after_variations_table' ); ?> 87 88 88 89 <div class="single_variation_wrap"> 89 90 <?php 90 /**91 * Hookwoocommerce_before_single_variation.92 */93 do_action( 'woocommerce_before_single_variation' );91 /** 92 * Hook: woocommerce_before_single_variation. 93 */ 94 do_action( 'woocommerce_before_single_variation' ); 94 95 95 /** 96 * Hook woocommerce_single_variation. 97 * 98 * Used to output the cart button and placeholder for variation data. 99 * 100 * @since 2.4.0 101 * @hooked woocommerce_single_variation - 10 Empty div for variation data. 102 * @hooked woocommerce_single_variation_add_to_cart_button - 20 Qty and cart button. 103 */ 104 do_action( 'woocommerce_single_variation' ); 96 /** 97 * Hook: woocommerce_single_variation. Used to output the cart button and placeholder for variation data. 98 * 99 * @since 2.4.0 100 * @hooked woocommerce_single_variation - 10 Empty div for variation data. 101 * @hooked woocommerce_single_variation_add_to_cart_button - 20 Qty and cart button. 102 */ 103 do_action( 'woocommerce_single_variation' ); 105 104 106 /**107 * Hookwoocommerce_after_single_variation.108 */109 do_action( 'woocommerce_after_single_variation' );105 /** 106 * Hook: woocommerce_after_single_variation. 107 */ 108 do_action( 'woocommerce_after_single_variation' ); 110 109 ?> 111 110 </div> 112 113 111 <?php endif; ?> 114 112 … … 116 114 </form> 117 115 118 <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?> 116 <?php 117 do_action( 'woocommerce_after_add_to_cart_form' ); -
sizeme-for-woocommerce/trunk/classes/class-wc-settings-sizeme-for-woocommerce.php
r2293215 r2942526 229 229 ), 230 230 array( 231 'title' => __( 'Match male gender from product name', 'sizeme-for-woocommerce' ), 232 'type' => 'text', 233 'default' => get_option( WC_SizeMe_for_WooCommerce::MATCH_GENDER_FROM_NAME_MALE, '' ), 234 'id' => WC_SizeMe_for_WooCommerce::MATCH_GENDER_FROM_NAME_MALE, 235 ), 236 array( 237 'title' => __( 'Measurement unit', 'sizeme-for-woocommerce' ), 238 'type' => 'radio', 239 'options' => array( 240 'cm' => 'Metric [cm]', 241 'in' => 'Imperial [in]', 242 ), 243 'default' => get_option( WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT, 'cm' ), 244 'id' => WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT, 245 ), 246 array( 247 'title' => __( 'Disallow user from changing measurement unit', 'sizeme-for-woocommerce' ), 248 'type' => 'select', 249 'options' => array( 250 self::ADD_TOGGLER_NO => 'No', // re-using setting 251 self::ADD_TOGGLER_YES => 'Yes', 252 ), 253 'default' => get_option( WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT_CHOICE_DISALLOWED, self::ADD_TOGGLER_NO ), 254 'id' => WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT_CHOICE_DISALLOWED, 255 ), 256 array( 231 257 'title' => __( 'Custom styles', 'sizeme-for-woocommerce' ), 232 258 'type' => 'textarea', -
sizeme-for-woocommerce/trunk/readme.txt
r2856957 r2942526 3 3 Tags: sizeme, measurements, sizeguide, size guide, size recommendations 4 4 Requires at least: 3.8 5 Tested up to: 6. 1.16 Stable tag: 2. 2.35 Tested up to: 6.2.2 6 Stable tag: 2.3.0 7 7 Requires PHP: 5.2.4 8 8 WC requires at least: 2.5 9 WC tested up to: 7. 3.09 WC tested up to: 7.9.0 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 83 83 84 84 == Changelog == 85 = 2.3.0 = 86 * Added metric to imperial measurement switch with corresponding options 87 * Added possibility to specify which products are for men to show correct measurement guide videos 88 85 89 = 2.2.3 = 86 90 * Discontinued sending unused email hash -
sizeme-for-woocommerce/trunk/sizeme-for-woocommerce.php
r2856957 r2942526 10 10 * Plugin Name: SizeMe for WooCommerce 11 11 * 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. 12 * Version: 2. 2.312 * Version: 2.3.0 13 13 * Author: SizeMe Ltd 14 14 * Author URI: https://www.sizeme.com/ … … 17 17 * 18 18 * WC requires at least: 2.5 19 * WC tested up to: 7. 3.019 * WC tested up to: 7.9.0 20 20 * 21 21 * SizeMe for WooCommerce is free software: you can redistribute it and/or modify … … 54 54 * @var string VERSION The plugin version. 55 55 */ 56 const VERSION = '2. 2.3';56 const VERSION = '2.3.0'; 57 57 58 58 /** … … 238 238 239 239 /** 240 * UI option, m ax recommendation distance, used in settings.240 * UI option, multiselect, size attributes, used to write correct variations to sizeme_product object. 241 241 * 242 242 * @since 2.1.0 243 243 * 244 * @var string MAX_RECOMMENDATION_DISTANCE The key for UI option.244 * @var string SIZE_ATTRIBUTES_KEY The key to store size attributes in wp_options. 245 245 */ 246 246 const SIZE_ATTRIBUTES_KEY = 'sizeme_size_attributes'; 247 247 248 /** 249 * Info related to SizeMe API requests 248 /** 249 * UI option, reg exp string to identify the male gender from product name and/or SKU. 250 * 251 * @since 2.3.0 252 * 253 * @var string MATCH_GENDER_FROM_NAME_MALE Optional string. 254 */ 255 const MATCH_GENDER_FROM_NAME_MALE = 'sizeme_match_gender_from_name_male'; 256 257 /** 258 * UI option, string for default measurement unit: supports "cm" and "in" currently 259 * 260 * @since 2.3.0 261 * 262 * @var string MEASUREMENT_UNIT string. 263 */ 264 const MEASUREMENT_UNIT = 'sizeme_measurement_unit'; 265 266 /** 267 * UI option, select to disallow user from selecting measurement unit 268 * 269 * @since 2.3.0 270 * 271 * @var boolean MEASUREMENT_UNIT_CHOICE_DISALLOWED. 272 */ 273 const MEASUREMENT_UNIT_CHOICE_DISALLOWED = 'sizeme_measurement_unit_choice_disallowed'; 274 275 /** 276 * Info related to SizeMe API requests 250 277 * 251 278 * @since 2.0.0 … … 419 446 420 447 /** 421 * Get the togglerboolean state.422 * 423 * Gets the togglerboolean state from the configuration.448 * Get a boolean state. 449 * 450 * Gets the a boolean state from the configuration. 424 451 * Either 'no' or 'yes' 425 452 * 426 453 * @since 2.0.0 454 * @changed 2.3.0 427 455 * 428 456 * @return string The toggler status as a string. 429 457 */ 430 public function is_toggler_yes( ) {431 return ( get_option( self::ADD_TOGGLER) == 'yes' );458 public function is_toggler_yes( $option ) { 459 return ( get_option( $option ) == 'yes' ); 432 460 } 433 461 … … 961 989 protected function migrate_possible_options() { 962 990 // Check if the sizeme_version option has been set. If it's not present, previous (non-prefixed) option keys are likely to been set. 963 if ( get_option('sizeme_version', NULL) === NULL ) { 991 $current_sizeme_version = get_option('sizeme_version', NULL); 992 if ( $current_sizeme_version === NULL ) { 964 993 // Check if there actually are old options present 965 994 if ( get_option('service_status', NULL) !== NULL ) { … … 985 1014 } 986 1015 1016 /* 1017 // Add new option from version 2.3.0 onward 1018 if (version_compare($current_sizeme_version, '2.3.0', '>=')) { 1019 add_option('new_option_name', 'default_value'); 1020 } 1021 */ 1022 987 1023 return true; 988 1024 } -
sizeme-for-woocommerce/trunk/templates/sizeme-product.php
r2293215 r2942526 55 55 'addToCartElement' => WC_SizeMe_for_WooCommerce::ADD_TO_CART_ELEMENT, 56 56 'addToCartEvent' => WC_SizeMe_for_WooCommerce::ADD_TO_CART_EVENT, 57 'lang' => WC_SizeMe_for_WooCommerce::LANG_OVERRIDE 57 'lang' => WC_SizeMe_for_WooCommerce::LANG_OVERRIDE, 58 'measurementUnit' => WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT, 58 59 ); 59 60 … … 65 66 66 67 // TOGGLER 67 if ( $sizeme->is_toggler_yes( ) ) {68 echo 'sizeme_options.uiOptions.toggler = "true";'.PHP_EOL;68 if ( $sizeme->is_toggler_yes( WC_SizeMe_for_WooCommerce::ADD_TOGGLER ) ) { 69 echo 'sizeme_options.uiOptions.toggler = true;'.PHP_EOL; 69 70 } 70 71 … … 76 77 $dist = intval( $sizeme->get_ui_option( WC_SizeMe_for_WooCommerce::MAX_RECOMMENDATION_DISTANCE, '' ) ); 77 78 if ( $dist > 0 ) printf('sizeme_options.uiOptions.maxRecommendationDistance = %d;'.PHP_EOL, $dist ); 79 80 // possible measurementUnitChoiceDisallowed 81 if ( $sizeme->is_toggler_yes( WC_SizeMe_for_WooCommerce::MEASUREMENT_UNIT_CHOICE_DISALLOWED ) ) { 82 echo 'sizeme_options.uiOptions.measurementUnitChoiceDisallowed = true;'.PHP_EOL; 83 } 84 85 // possible string 86 $gender_string = trim( $sizeme->get_ui_option( WC_SizeMe_for_WooCommerce::MATCH_GENDER_FROM_NAME_MALE, '' ) ); 87 if ( !empty($gender_string) ) echo 'sizeme_options.uiOptions.matchGenderFromNameMale = "' . htmlspecialchars( $gender_string ) . '";'.PHP_EOL; 88 78 89 ?> 79 90 -
sizeme-for-woocommerce/trunk/woocommerce/single-product/add-to-cart/variable.php
r2293215 r2942526 8 8 * will need to copy the new files to your theme to maintain compatibility. 9 9 * 10 * Last checked against WC version 3.4.110 * Last harmonized against WooCommerce\Templates version 6.1.0 11 11 * 12 12 * @see WC_SizeMe_for_WooCommerce::locate_template … … 34 34 */ 35 35 36 if ( ! defined( 'ABSPATH' ) ) { 37 exit; // Exit if accessed directly. 38 } 36 defined( 'ABSPATH' ) || exit; 39 37 40 38 global $product; … … 43 41 44 42 $attribute_keys = array_keys( $attributes ); 43 $variations_json = wp_json_encode( $available_variations ); 44 $variations_attr = function_exists( 'wc_esc_json' ) ? wc_esc_json( $variations_json ) : _wp_specialchars( $variations_json, ENT_QUOTES, 'UTF-8', true ); 45 45 46 46 do_action( 'woocommerce_before_add_to_cart_form' ); ?> 47 47 48 <form class="variations_form cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $product->get_id() ); ?>" data-product_variations="<?php echo htmlspecialchars( wp_json_encode( $available_variations ) ); // WPCS: XSS ok. ?>">48 <form class="variations_form cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $product->get_id() ); ?>" data-product_variations="<?php echo $variations_attr; // WPCS: XSS ok. ?>"> 49 49 <?php do_action( 'woocommerce_before_variations_form' ); ?> 50 50 51 51 <?php if ( empty( $available_variations ) && false !== $available_variations ) : ?> 52 <p class="stock out-of-stock"><?php e sc_attr_e( 'This product is currently out of stock and unavailable.', 'woocommerce'); ?></p>52 <p class="stock out-of-stock"><?php echo esc_html( apply_filters( 'woocommerce_out_of_stock_message', __( 'This product is currently out of stock and unavailable.', 'woocommerce' ) ) ); ?></p> 53 53 <?php else : ?> 54 <table class="variations" cellspacing="0" >54 <table class="variations" cellspacing="0" role="presentation"> 55 55 <tbody> 56 <?php 57 $size_set = false; 58 foreach ( $attributes as $attribute_name => $options ) : 59 $selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? 60 wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : 61 $product->get_variation_default_attribute( $attribute_name ); // Input var okay. 62 63 if ( $sizeme->is_size_attribute( $product, $attribute_name ) && ! $size_set ) { 64 $class = 'sizeme-selection-container'; 65 $size_set = true; 66 } else { 67 $class = ''; 68 } ?> 69 <tr> 70 <td class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo wc_attribute_label( $attribute_name ); // WPCS: XSS ok. ?></label></td> 71 <td class="value<?php echo $class !== '' ? ' ' . esc_attr( $class ) : ''; ?>"> 72 <?php 73 wc_dropdown_variation_attribute_options( array( 74 'options' => $options, 75 'attribute' => $attribute_name, 76 'product' => $product, 77 ) ); 78 echo end( $attribute_keys ) === $attribute_name ? wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '<a class="reset_variations" href="#">' . esc_html__( 'Clear', 'woocommerce' ) . '</a>' ) ) : ''; 79 ?> 80 </td> 81 </tr> 82 <?php endforeach; ?> 56 <?php $size_set = false; ?> 57 <?php foreach ( $attributes as $attribute_name => $options ) : ?> 58 <?php 59 if ( $sizeme->is_size_attribute( $product, $attribute_name ) && ! $size_set ) { 60 $class = 'sizeme-selection-container'; 61 $size_set = true; 62 } else { 63 $class = ''; 64 } 65 ?> 66 <tr> 67 <th class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo wc_attribute_label( $attribute_name ); // WPCS: XSS ok. ?></label></th> 68 <td class="value<?php echo $class !== '' ? ' ' . esc_attr( $class ) : ''; ?>"> 69 <?php 70 wc_dropdown_variation_attribute_options( 71 array( 72 'options' => $options, 73 'attribute' => $attribute_name, 74 'product' => $product, 75 ) 76 ); 77 echo end( $attribute_keys ) === $attribute_name ? wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '<a class="reset_variations" href="#">' . esc_html__( 'Clear', 'woocommerce' ) . '</a>' ) ) : ''; 78 ?> 79 </td> 80 </tr> 81 <?php endforeach; ?> 83 82 </tbody> 84 83 </table> 85 84 86 85 <div class="sizeme-container"></div> 86 87 <?php do_action( 'woocommerce_after_variations_table' ); ?> 87 88 88 89 <div class="single_variation_wrap"> 89 90 <?php 90 /**91 * Hookwoocommerce_before_single_variation.92 */93 do_action( 'woocommerce_before_single_variation' );91 /** 92 * Hook: woocommerce_before_single_variation. 93 */ 94 do_action( 'woocommerce_before_single_variation' ); 94 95 95 /** 96 * Hook woocommerce_single_variation. 97 * 98 * Used to output the cart button and placeholder for variation data. 99 * 100 * @since 2.4.0 101 * @hooked woocommerce_single_variation - 10 Empty div for variation data. 102 * @hooked woocommerce_single_variation_add_to_cart_button - 20 Qty and cart button. 103 */ 104 do_action( 'woocommerce_single_variation' ); 96 /** 97 * Hook: woocommerce_single_variation. Used to output the cart button and placeholder for variation data. 98 * 99 * @since 2.4.0 100 * @hooked woocommerce_single_variation - 10 Empty div for variation data. 101 * @hooked woocommerce_single_variation_add_to_cart_button - 20 Qty and cart button. 102 */ 103 do_action( 'woocommerce_single_variation' ); 105 104 106 /**107 * Hookwoocommerce_after_single_variation.108 */109 do_action( 'woocommerce_after_single_variation' );105 /** 106 * Hook: woocommerce_after_single_variation. 107 */ 108 do_action( 'woocommerce_after_single_variation' ); 110 109 ?> 111 110 </div> 112 113 111 <?php endif; ?> 114 112 … … 116 114 </form> 117 115 118 <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?> 116 <?php 117 do_action( 'woocommerce_after_add_to_cart_form' );
Note: See TracChangeset
for help on using the changeset viewer.