Commit cea4aae8 authored by Sujeet's avatar Sujeet

Using config.

parent edf365ae
...@@ -17,6 +17,10 @@ $tabStyle = $_config->getProductDetail('tab_style'); ...@@ -17,6 +17,10 @@ $tabStyle = $_config->getProductDetail('tab_style');
$product = $objectManager->get('Magento\Catalog\Model\Product')->load($currentProduct->getId()); $product = $objectManager->get('Magento\Catalog\Model\Product')->load($currentProduct->getId());
$length = $product->getCustomAttribute('ts_dimensions_length')->getValue(); $length = $product->getCustomAttribute('ts_dimensions_length')->getValue();
$width = $product->getCustomAttribute('ts_dimensions_width')->getValue(); $width = $product->getCustomAttribute('ts_dimensions_width')->getValue();
$configModel = $objectManager->get('Magento\Variable\Model\Variable')->loadByCode('PRODUCT_SIZE_CONFIG');
$config_value = $configModel->getPlainValue();
if (!empty($width) && !empty($length)) { ?> if (!empty($width) && !empty($length)) { ?>
<script> <script>
require([ require([
...@@ -25,21 +29,22 @@ $tabStyle = $_config->getProductDetail('tab_style'); ...@@ -25,21 +29,22 @@ $tabStyle = $_config->getProductDetail('tab_style');
'use strict'; 'use strict';
if (jQuery('#product_addtocart_form').find('.product-options-wrapper').length) { if (jQuery('#product_addtocart_form').find('.product-options-wrapper').length) {
setTimeout(function(){ setTimeout(function(){
var config = { /*var config = {
S: 10, S: 10,
M: 20, M: 20,
L: 30, L: 30,
XL: 40, XL: 40,
XXL: 50, XXL: 50,
XXXL: 60, XXXL: 60,
}; }; */
var config = <?php echo $config_value; ?>;
var baseHeight = <?php echo $length; ?>; var baseHeight = <?php echo $length; ?>;
var baseWidth = <?php echo $width; ?>; var baseWidth = <?php echo $width; ?>;
jQuery('#product_addtocart_form #select_2 option').each(function(){ jQuery('#product_addtocart_form #select_2 option').each(function(){
var $this = $(this); var $this = $(this);
var value = $this.text(); var value = $this.text();
var percent = parseInt(config[value]); var percent = parseInt(config[value]);
console.log("------------------------", `==${value}==`, percent, config, config[value]); // console.log("------------------------", `==${value}==`, percent, config, config[value]);
if (percent && percent > 0) { if (percent && percent > 0) {
var heigth = parseInt(baseHeight + (baseHeight * percent / 100)); var heigth = parseInt(baseHeight + (baseHeight * percent / 100));
var width = parseInt(baseWidth + (baseWidth * percent / 100)); var width = parseInt(baseWidth + (baseWidth * percent / 100));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment