Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE_AFL.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magento.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magento.com for more information.
- *
- * @category design
- * @package base_default
- * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
- */
- /* @var $this Mage_Catalog_Block_Product_View_Options */
- ?>
- <?php $_options = Mage::helper('core')->decorateArray($this->getOptions()) ?>
- <?php if (count($_options)):?>
- <dl>
- <?php $options_to_sku = array();?>
- <?php foreach($_options as $_option): ?>
- <?php echo $this->getOptionHtml($_option) ?>
- <?php
- if ($_option->getType() == 'drop_down')
- {
- $options_to_sku["{$_option->getId()}"] = array();
- foreach ($_option->getValues() as $k => $v)
- {
- $options_to_sku["{$_option->getId()}"]["{$v->getData('option_type_id')}"] = $v->getData('sku');
- }
- }
- ?>
- <?php endforeach; ?>
- </dl>
- <script type="text/javascript">
- var options_to_sku = <?php echo json_encode($options_to_sku);?>;
- $$('.product-custom-option').each(function(elm) {
- $(elm).observe('change', function() {
- var sku_suffix = '';
- $$('.product-custom-option').each(function(opt) {
- if ($(opt).value.length==0) // no value selected
- return;
- var opt_id = $(opt).readAttribute('id').replace('select_','');
- if (!!!options_to_sku[opt_id]) // no option values array found
- return;
- if (!!!options_to_sku[opt_id][$(opt).value]) // no sku found matching value id
- return;
- sku_suffix += '-' + options_to_sku[opt_id][$(opt).value]; // add to suffix
- });
- /**
- * add here the code that adds the suffix to your SKU
- */
- console.log(sku_suffix);
- });
- });
- $("sku-container").update("<strong>Configuration: <?php echo $this->getProduct()->getSku(); ?></strong>" + (sku_suffix));
- </script>
- <div id="sku-container"></div>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement