Plugin Directory

Changeset 2942526


Ignore:
Timestamp:
07/24/2023 12:14:30 PM (3 years ago)
Author:
sizeme
Message:

Added imperial unit switching options

Location:
sizeme-for-woocommerce
Files:
8 edited
3 copied

Legend:

Unmodified
Added
Removed
  • sizeme-for-woocommerce/tags/2.3.0/classes/class-wc-settings-sizeme-for-woocommerce.php

    r2293215 r2942526  
    229229            ),
    230230            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(
    231257                'title'   => __( 'Custom styles', 'sizeme-for-woocommerce' ),
    232258                'type'    => 'textarea',
  • sizeme-for-woocommerce/tags/2.3.0/readme.txt

    r2856957 r2942526  
    33Tags: sizeme, measurements, sizeguide, size guide, size recommendations
    44Requires at least: 3.8
    5 Tested up to: 6.1.1
    6 Stable tag: 2.2.3
     5Tested up to: 6.2.2
     6Stable tag: 2.3.0
    77Requires PHP: 5.2.4
    88WC requires at least: 2.5
    9 WC tested up to: 7.3.0
     9WC tested up to: 7.9.0
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8383
    8484== 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
    8589= 2.2.3 =
    8690* Discontinued sending unused email hash
  • sizeme-for-woocommerce/tags/2.3.0/sizeme-for-woocommerce.php

    r2856957 r2942526  
    1010 * Plugin Name: SizeMe for WooCommerce
    1111 * 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.3
     12 * Version:     2.3.0
    1313 * Author:      SizeMe Ltd
    1414 * Author URI:  https://www.sizeme.com/
     
    1717 *
    1818 * WC requires at least: 2.5
    19  * WC tested up to: 7.3.0
     19 * WC tested up to: 7.9.0
    2020 *
    2121 * SizeMe for WooCommerce is free software: you can redistribute it and/or modify
     
    5454     * @var string VERSION The plugin version.
    5555     */
    56     const VERSION = '2.2.3';
     56    const VERSION = '2.3.0';
    5757
    5858    /**
     
    238238
    239239    /**
    240      * UI option, max recommendation distance, used in settings.
     240     * UI option, multiselect, size attributes, used to write correct variations to sizeme_product object.
    241241     *
    242242     * @since 2.1.0
    243243     *
    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.
    245245     */
    246246    const SIZE_ATTRIBUTES_KEY = 'sizeme_size_attributes';
    247247
    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
    250277     *
    251278     * @since 2.0.0
     
    419446
    420447    /**
    421      * Get the toggler boolean state.
    422      *
    423      * Gets the toggler boolean state from the configuration.
     448     * Get a boolean state.
     449     *
     450     * Gets the a boolean state from the configuration.
    424451     * Either 'no' or 'yes'
    425452     *
    426453     * @since  2.0.0
     454     * @changed  2.3.0
    427455     *
    428456     * @return string The toggler status as a string.
    429457     */
    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' );
    432460    }
    433461
     
    961989    protected function migrate_possible_options() {
    962990        // 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 ) {
    964993            // Check if there actually are old options present
    965994            if ( get_option('service_status', NULL) !== NULL ) {
     
    9851014        }
    9861015
     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
    9871023        return true;
    9881024    }
  • sizeme-for-woocommerce/tags/2.3.0/templates/sizeme-product.php

    r2293215 r2942526  
    5555        'addToCartElement' => WC_SizeMe_for_WooCommerce::ADD_TO_CART_ELEMENT,
    5656        '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,
    5859    );
    5960
     
    6566
    6667    // 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;
    6970    }
    7071
     
    7677    $dist = intval( $sizeme->get_ui_option( WC_SizeMe_for_WooCommerce::MAX_RECOMMENDATION_DISTANCE, '' ) );
    7778    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
    7889    ?>
    7990
  • sizeme-for-woocommerce/tags/2.3.0/woocommerce/single-product/add-to-cart/variable.php

    r2293215 r2942526  
    88 * will need to copy the new files to your theme to maintain compatibility.
    99 *
    10  * Last checked against WC version 3.4.1
     10 * Last harmonized against WooCommerce\Templates version 6.1.0
    1111 *
    1212 * @see     WC_SizeMe_for_WooCommerce::locate_template
     
    3434 */
    3535
    36 if ( ! defined( 'ABSPATH' ) ) {
    37     exit; // Exit if accessed directly.
    38 }
     36defined( 'ABSPATH' ) || exit;
    3937
    4038global $product;
     
    4341
    4442$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 );
    4545
    4646do_action( 'woocommerce_before_add_to_cart_form' ); ?>
    4747
    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. ?>">
    4949    <?php do_action( 'woocommerce_before_variations_form' ); ?>
    5050
    5151    <?php if ( empty( $available_variations ) && false !== $available_variations ) : ?>
    52         <p class="stock out-of-stock"><?php esc_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>
    5353    <?php else : ?>
    54         <table class="variations" cellspacing="0">
     54        <table class="variations" cellspacing="0" role="presentation">
    5555            <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; ?>
    8382            </tbody>
    8483        </table>
    85        
     84
    8685        <div class="sizeme-container"></div>
     86
     87        <?php do_action( 'woocommerce_after_variations_table' ); ?>
    8788
    8889        <div class="single_variation_wrap">
    8990            <?php
    90             /**
    91              * Hook woocommerce_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' );
    9495
    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' );
    105104
    106             /**
    107              * Hook woocommerce_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' );
    110109            ?>
    111110        </div>
    112 
    113111    <?php endif; ?>
    114112
     
    116114</form>
    117115
    118 <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
     116<?php
     117do_action( 'woocommerce_after_add_to_cart_form' );
  • sizeme-for-woocommerce/trunk/classes/class-wc-settings-sizeme-for-woocommerce.php

    r2293215 r2942526  
    229229            ),
    230230            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(
    231257                'title'   => __( 'Custom styles', 'sizeme-for-woocommerce' ),
    232258                'type'    => 'textarea',
  • sizeme-for-woocommerce/trunk/readme.txt

    r2856957 r2942526  
    33Tags: sizeme, measurements, sizeguide, size guide, size recommendations
    44Requires at least: 3.8
    5 Tested up to: 6.1.1
    6 Stable tag: 2.2.3
     5Tested up to: 6.2.2
     6Stable tag: 2.3.0
    77Requires PHP: 5.2.4
    88WC requires at least: 2.5
    9 WC tested up to: 7.3.0
     9WC tested up to: 7.9.0
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8383
    8484== 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
    8589= 2.2.3 =
    8690* Discontinued sending unused email hash
  • sizeme-for-woocommerce/trunk/sizeme-for-woocommerce.php

    r2856957 r2942526  
    1010 * Plugin Name: SizeMe for WooCommerce
    1111 * 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.3
     12 * Version:     2.3.0
    1313 * Author:      SizeMe Ltd
    1414 * Author URI:  https://www.sizeme.com/
     
    1717 *
    1818 * WC requires at least: 2.5
    19  * WC tested up to: 7.3.0
     19 * WC tested up to: 7.9.0
    2020 *
    2121 * SizeMe for WooCommerce is free software: you can redistribute it and/or modify
     
    5454     * @var string VERSION The plugin version.
    5555     */
    56     const VERSION = '2.2.3';
     56    const VERSION = '2.3.0';
    5757
    5858    /**
     
    238238
    239239    /**
    240      * UI option, max recommendation distance, used in settings.
     240     * UI option, multiselect, size attributes, used to write correct variations to sizeme_product object.
    241241     *
    242242     * @since 2.1.0
    243243     *
    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.
    245245     */
    246246    const SIZE_ATTRIBUTES_KEY = 'sizeme_size_attributes';
    247247
    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
    250277     *
    251278     * @since 2.0.0
     
    419446
    420447    /**
    421      * Get the toggler boolean state.
    422      *
    423      * Gets the toggler boolean state from the configuration.
     448     * Get a boolean state.
     449     *
     450     * Gets the a boolean state from the configuration.
    424451     * Either 'no' or 'yes'
    425452     *
    426453     * @since  2.0.0
     454     * @changed  2.3.0
    427455     *
    428456     * @return string The toggler status as a string.
    429457     */
    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' );
    432460    }
    433461
     
    961989    protected function migrate_possible_options() {
    962990        // 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 ) {
    964993            // Check if there actually are old options present
    965994            if ( get_option('service_status', NULL) !== NULL ) {
     
    9851014        }
    9861015
     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
    9871023        return true;
    9881024    }
  • sizeme-for-woocommerce/trunk/templates/sizeme-product.php

    r2293215 r2942526  
    5555        'addToCartElement' => WC_SizeMe_for_WooCommerce::ADD_TO_CART_ELEMENT,
    5656        '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,
    5859    );
    5960
     
    6566
    6667    // 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;
    6970    }
    7071
     
    7677    $dist = intval( $sizeme->get_ui_option( WC_SizeMe_for_WooCommerce::MAX_RECOMMENDATION_DISTANCE, '' ) );
    7778    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
    7889    ?>
    7990
  • sizeme-for-woocommerce/trunk/woocommerce/single-product/add-to-cart/variable.php

    r2293215 r2942526  
    88 * will need to copy the new files to your theme to maintain compatibility.
    99 *
    10  * Last checked against WC version 3.4.1
     10 * Last harmonized against WooCommerce\Templates version 6.1.0
    1111 *
    1212 * @see     WC_SizeMe_for_WooCommerce::locate_template
     
    3434 */
    3535
    36 if ( ! defined( 'ABSPATH' ) ) {
    37     exit; // Exit if accessed directly.
    38 }
     36defined( 'ABSPATH' ) || exit;
    3937
    4038global $product;
     
    4341
    4442$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 );
    4545
    4646do_action( 'woocommerce_before_add_to_cart_form' ); ?>
    4747
    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. ?>">
    4949    <?php do_action( 'woocommerce_before_variations_form' ); ?>
    5050
    5151    <?php if ( empty( $available_variations ) && false !== $available_variations ) : ?>
    52         <p class="stock out-of-stock"><?php esc_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>
    5353    <?php else : ?>
    54         <table class="variations" cellspacing="0">
     54        <table class="variations" cellspacing="0" role="presentation">
    5555            <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; ?>
    8382            </tbody>
    8483        </table>
    85        
     84
    8685        <div class="sizeme-container"></div>
     86
     87        <?php do_action( 'woocommerce_after_variations_table' ); ?>
    8788
    8889        <div class="single_variation_wrap">
    8990            <?php
    90             /**
    91              * Hook woocommerce_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' );
    9495
    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' );
    105104
    106             /**
    107              * Hook woocommerce_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' );
    110109            ?>
    111110        </div>
    112 
    113111    <?php endif; ?>
    114112
     
    116114</form>
    117115
    118 <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
     116<?php
     117do_action( 'woocommerce_after_add_to_cart_form' );
Note: See TracChangeset for help on using the changeset viewer.