Exemplo n.º 1
0
 /**
  * Load elements css/js assets
  * @return $this
  */
 public function loadAssets()
 {
     parent::loadAssets();
     // for cache mode
     $this->less('jbassets:less/widget/quantity.less');
     $this->js(array('jbassets:js/widget/quantity.js', 'cart-elements:price/quantity/assets/js/quantity.js'));
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Get elements value
  * @param string $key      Array key.
  * @param mixed  $default  Default value if data is empty.
  * @param bool   $toString A string representation of the value.
  * @return mixed|string
  */
 public function getValue($toString = false, $key = 'value', $default = null)
 {
     $value = parent::getValue($toString, $key, $default);
     if (empty($value) && ($item = $this->_jbprice->getItem())) {
         $value = $item->id;
     }
     $value = JString::trim($value);
     return $value;
 }
Exemplo n.º 3
0
 /**
  * Get elements value
  * @param string $key      Array key.
  * @param mixed  $default  Default value if data is empty.
  * @param bool   $toString A string representation of the value.
  * @return mixed|string
  */
 public function getValue($toString = false, $key = 'value', $default = null)
 {
     $value = parent::getValue($toString, $key, $default);
     $value = $this->clearSymbols($value, array('-', '+'));
     if ($toString) {
         return $value;
     }
     return JBCart::val($value);
 }
Exemplo n.º 4
0
 /**
  * Get elements value
  * @param array|string $key      Array key.
  * @param mixed        $default  Default value if data is empty.
  * @param bool         $toString A string representation of the value.
  * @return mixed|string
  */
 public function getValue($toString = false, $key = array('height', 'length', 'width'), $default = null)
 {
     if (is_string($key) && $toString) {
         $value = parent::getValue($toString, $key, $default);
     } elseif ($toString) {
         $value = call_user_func_array('parent::getValue', $key);
     } else {
         $callable = array($this, 'getValue');
         array_walk($key, function ($_val) use(&$value, $callable) {
             $value[$_val] = call_user_func($callable, array(true, $_val));
         });
     }
     return $value;
 }
Exemplo n.º 5
0
 /**
  * Load elements css/js assets
  * @return $this
  */
 public function loadEditAssets()
 {
     $this->app->jbassets->js('jbassets:js/widget/media.js');
     return parent::loadEditAssets();
 }
Exemplo n.º 6
0
 /**
  * @param  JBCartElementPrice $element
  * @param  ElementJBPrice     $jbPrice
  * @param  array              $options
  * @return \JBCSVItemPrice
  */
 public function csvItem($element, $jbPrice, $options = array())
 {
     if (empty($jbPrice)) {
         return false;
     }
     if ($element instanceof JBCartElementPrice) {
         $type = $element->getElementType();
     } else {
         $type = $element;
     }
     // load table class
     $class = 'JBCSVItemPrice' . $type;
     if (!class_exists('JBCSVItemPrice')) {
         $this->app->loader->register('JBCSVItemPrice', 'jbelements:price/price.php');
     }
     if (!class_exists($class)) {
         $this->app->loader->register($class, 'jbelements:' . self::ELEMENTS_CSV_GROUP . '/' . strtolower($type) . '.php');
     }
     if (class_exists($class)) {
         $instance = new $class($element, $jbPrice, $options);
     } else {
         $instance = new JBCSVItemPrice($element, $jbPrice, $options);
     }
     return $instance;
 }
Exemplo n.º 7
0
 /**
  * Check if option isset in element
  * @param JBCartElementPrice $element
  * @param                    $value
  * @return bool|string
  */
 public function issetOption($element, $value)
 {
     $element->bindData($value);
     $value = $element->getValue();
     if ($element->hasOption($value)) {
         return $value;
     }
     return false;
 }
Exemplo n.º 8
0
 /**
  * @return $this
  */
 public function loadAssets()
 {
     // for cache mode
     $this->js(array('jbassets:js/widget/money.js', 'jbassets:js/widget/currencytoggle.js'));
     $this->less('jbassets:less/widget/currencytoggle.less');
     return parent::loadAssets();
 }
Exemplo n.º 9
0
 /**
  * @param JBCartElementPrice $element
  * @param array|string       elements data
  * @return mixed
  */
 protected function setElement($element, $data)
 {
     if (is_array($data) && !empty($data)) {
         $data = array_filter($data, function ($value) {
             return $value !== '' && $value !== null;
         });
     }
     $element->setVariant($this->id);
     if ($this->list instanceof JBCartVariantList && !$this->isBasic()) {
         $basic = $this->list->first()->getValue(true, $element->identifier);
         if ($basic !== null && $basic !== '') {
             $data['_basic'] = $basic;
         }
     }
     if (!empty($data)) {
         $element->bindData($data);
     }
     return $element;
 }