Exemplo n.º 1
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.º 2
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;
 }