Skip to content

Commit

Permalink
Merge pull request #13 from nomasi/add-max-recommendation-distance
Browse files Browse the repository at this point in the history
Add max recommendation distance in settings
  • Loading branch information
nomasi authored Mar 9, 2020
2 parents 5e0c52f + 99586e5 commit ff3ca12
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions classes/class-wc-settings-sizeme-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ public function get_settings() {
'default' => get_option( WC_SizeMe_for_WooCommerce::LANG_OVERRIDE, '' ),
'id' => WC_SizeMe_for_WooCommerce::LANG_OVERRIDE,
),
array(
'title' => __( 'Maximum recommendation distance', 'sizeme-for-woocommerce' ),
'type' => 'text',
'default' => get_option( WC_SizeMe_for_WooCommerce::MAX_RECOMMENDATION_DISTANCE, '' ),
'id' => WC_SizeMe_for_WooCommerce::MAX_RECOMMENDATION_DISTANCE,
),
array(
'title' => __( 'Custom styles', 'sizeme-for-woocommerce' ),
'type' => 'textarea',
Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Contributors: sizeme
Tags: sizeme, measurements, size guide, size recommendations
Requires at least: 3.8
Tested up to: 5.3.2
Stable tag: 2.0.9
Stable tag: 2.1.0
Requires PHP: 5.2.4
WC requires at least: 2.5
WC tested up to: 3.9.2
WC tested up to: 3.9.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -83,6 +83,9 @@ To install and take into use the SizeMe for WooCommerce plugin, follow the instr

== Changelog ==

= 2.1.0 =
* Added support for the maximum recommendation distance setting. Used if you don't want to recommend sizes that are too far from the optimal size.

= 2.0.9 =
* Fixed sizeme_product object if the product's attribute is not global (product-specific)

Expand Down
13 changes: 11 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.9
* Version: 2.1.0
* 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.9';
const VERSION = '2.1.0';

/**
* Minimum WordPress version this plugin works with, used for dependency checks.
Expand Down Expand Up @@ -215,6 +215,15 @@ class WC_SizeMe_for_WooCommerce {
*/
const ADDITIONAL_TRANSLATIONS = 'additional_translations';

/**
* UI option, max recommendation distance, used in settings.
*
* @since 2.1.0
*
* @var string MAX_RECOMMENDATION_DISTANCE The key for UI option.
*/
const MAX_RECOMMENDATION_DISTANCE = 'max_recommendation_distance';

/**
* Info related to SizeMe API requests
*
Expand Down
4 changes: 4 additions & 0 deletions templates/sizeme-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
// ADDITIONAL TRANSLATIONS (from the UI OPTIONS array)
$trans = trim( $sizeme->get_ui_option( WC_SizeMe_for_WooCommerce::ADDITIONAL_TRANSLATIONS, '' ) );
if ( !empty($trans) ) echo 'sizeme_options.additionalTranslations = {' . trim( $trans ) . '};'.PHP_EOL;

// possible MAX_RECOMMENDATION_DISTANCE (from the UI OPTIONS array)
$dist = intval( $sizeme->get_ui_option( WC_SizeMe_for_WooCommerce::MAX_RECOMMENDATION_DISTANCE, '' ) );
if ( $dist > 0 ) printf('sizeme_options.uiOptions.maxRecommendationDistance = %d;'.PHP_EOL, $dist );
?>

var sizeme_product = {
Expand Down

0 comments on commit ff3ca12

Please sign in to comment.