Skip to content

Commit

Permalink
Added support for maximum recommendation distance (integer)
Browse files Browse the repository at this point in the history
  • Loading branch information
nomasi committed Mar 9, 2020
1 parent d02a267 commit 99586e5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 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
9 changes: 9 additions & 0 deletions sizeme-for-woocommerce.php
Original file line number Diff line number Diff line change
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 99586e5

Please sign in to comment.