/** * Get the Eav Attributes for a particular entity * @param unknown_type $entity * @param unknown_type $id * @param boolean $only_enabled */ public static function getAttributes($entity, $id, $only_enabled = false, $editable_by = '') { // $sets[$entity][$id] static $sets; if (!is_array($sets)) { $sets = array(); } if (is_array($editable_by)) { $editable_by = implode(',', $editable_by); } else { if (!strlen($editable_by)) { $editable_by = '-1'; } } if (!isset($sets[$entity][$id][$editable_by])) { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = DSCModel::getInstance('EavAttributes', 'TiendaModel'); $model->setState('filter_entitytype', $entity); $model->setState('filter_entityid', $id); $model->setState('filter_enabled', '1'); if ($editable_by != '-1') { $model->setState('filter_editable', $editable_by); } $sets[$entity][$id][$editable_by] = $model->getList(); } // Let the plugins change the list of custom fields $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onAfterGetCustomFields', array(&$sets[$entity][$id][$editable_by], $entity, $id)); return $sets[$entity][$id][$editable_by]; }
public function getAttributes($oid = null) { $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } if (empty($this->{$k})) { return array(); } DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('OrderitemAttributes', 'CitruscartModel'); $model->setState('filter_orderitemid', $this->{$k}); return $model->getList(); }
/** * Run function after deleteing */ function delete($oid = null, $doReconciliation = true) { $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } if ($doReconciliation) { if ($oid) { $row = JTable::getInstance('ProductAttributes', 'TiendaTable'); $row->load($oid); $product_id = $row->product_id; } else { $product_id = $this->product_id; } } $db = $this->getDBO(); $db->setQuery('SET foreign_key_checks = 0;'); $db->query(); if ($return = parent::delete($oid)) { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = DSCModel::getInstance('ProductAttributeOptions', 'TiendaModel'); $model->setState('filter_attribute', $this->{$k}); if ($items = $model->getList()) { $table = $model->getTable(); foreach ($items as $item) { if (!$table->delete($item->productattributeoption_id)) { $this->setError($table->getError()); } } } if ($doReconciliation) { Tienda::load("TiendaHelperProduct", 'helpers.product'); TiendaHelperProduct::doProductQuantitiesReconciliation($product_id); } } $db->setQuery('SET foreign_key_checks = 1;'); $db->query(); return parent::check(); }
/** * * @param $oid * @return unknown_type */ function delete($oid = null, $doReconciliation = true) { $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } if ($doReconciliation) { if ($oid) { $row = JTable::getInstance('ProductComments', 'CitruscartTable'); $row->load($oid); $product_id = $row->product_id; } else { $product_id = $this->product_id; } } if (parent::delete($oid)) { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('ProductCommentsHelpfulness', 'CitruscartModel'); $model->setState('filter_comment', $this->{$k}); if ($items = $model->getList()) { $table = $model->getTable(); foreach ($items as $item) { if (!$table->delete($item->productcommentshelpfulness_id)) { $this->setError($table->getError()); } } } if ($doReconciliation) { $product = JTable::getInstance('Products', 'CitruscartTable'); $product->load($product_id); $product->updateOverallRating(); if (!$product->save()) { $this->setError($product->getError()); } } } return parent::check(); }
/** * Clean the cache * * @return void * * @since 11.1 */ public function clearCacheAuxiliary() { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = DSCModel::getInstance('ProductCategories', 'TiendaModel'); $model->clearCache(); $model = DSCModel::getInstance('ProductAttributeOptions', 'TiendaModel'); $model->clearCache(); $model = DSCModel::getInstance('ProductAttributeOptionValues', 'TiendaModel'); $model->clearCache(); $model = DSCModel::getInstance('ProductAttributes', 'TiendaModel'); $model->clearCache(); $model = DSCModel::getInstance('ProductCompare', 'TiendaModel'); $model->clearCache(); $model = DSCModel::getInstance('ProductFiles', 'TiendaModel'); $model->clearCache(); $model = DSCModel::getInstance('ProductPrices', 'TiendaModel'); $model->clearCache(); $model = DSCModel::getInstance('ProductRelations', 'TiendaModel'); $model->clearCache(); }
public function getCountry() { if (empty($this->country_id)) { return false; } DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('Countries', 'CitruscartModel'); $model->setId($this->country_id); return $model->getItem(); }
<legend> <?php echo JText::_('COM_TIENDA_ADD_NEW_RELATIONSHIP'); ?> </legend> <div id="new_relationship" class="dsc-wrap dsc-table"> <div class="dsc-row"> <div class="dsc-cell"> <?php echo TiendaSelect::relationship('', 'new_relationship_type'); ?> </div> <div class="dsc-cell"> <?php DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = DSCModel::getInstance('ElementProduct', 'TiendaModel'); echo $model->fetchElement('new_relationship_productid_to'); echo $model->clearElement('new_relationship_productid_to'); //<input name="new_relationship_productid_to" size="15" type="text" /> ?> <input name="new_relationship_productid_from" value="<?php echo @$row->product_id; ?> " type="hidden" /> </div> <div class="dsc-cell"> <input type="button" value="<?php echo JText::_('COM_TIENDA_ADD'); ?> " class="btn btn-success" onclick="tiendaAddRelationship('existing_relationships', '<?php
public function deleteItemsWithoutReconciliation($type, $oid = null, $doReconciliation = false) { $failed = false; $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('Product' . $type, 'CitruscartModel'); $model->setState('filter_productid', $this->{$k}); if ($items = $model->getList()) { $table = $model->getTable(); $table_pk = $table->getKeyName(); foreach ($items as $item) { if (!$table->delete($item->{$table_pk}, $doReconciliation)) { $errors = $table->getErrors(); if (!empty($errors)) { foreach ($errors as $key => $error) { $error = trim($error); if (!empty($error)) { $failed = true; $this->setError($error); } } } } } } if ($failed) { return false; } return true; }
/** * Gets the model * only creating it if it doesn't exist * * @return array */ function _getModel($name = '', $prefix = 'SampleModel', $config = array()) { if (empty($name)) { $name = $this->get('default_model', 'Base'); } $fullname = strtolower($prefix . $name); if (empty($this->_models[$fullname])) { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_sample/models'); if (!($model = DSCModel::getInstance($name, $prefix, $config))) { $model = new SampleModelBase(); } $this->_models[$fullname] = $model; } return $this->_models[$fullname]; }
/** * * @param array $values * @param boolean $saveAddressesToDB Save the addresses to the database * @param boolean $ajax * @return unknown_type */ public function setAddresses(&$values, $saveAddressesToDB = false, $ajax = false) { $clearAddressCache = false; $order = $this->_order; Citruscart::load('CitruscartHelperCurrency', 'helpers.currency'); $currency_id = CitruscartHelperCurrency::getCurrentCurrency(); $billing_address_id = !empty($values['billing_address_id']) ? $values['billing_address_id'] : 0; $shipping_address_id = !empty($values['shipping_address_id']) ? $values['shipping_address_id'] : 0; $same_as_billing = !empty($values['sameasbilling']) ? true : false; $user_id = $values['user_id']; $billing_input_prefix = $this->billing_input_prefix; $shipping_input_prefix = $this->shipping_input_prefix; if (empty($user_id) && $this->defines->get('guest_checkout_enabled', '1')) { $user_id = -1; } $billing_zone_id = 0; $billingAddressArray = $this->getAddressArray($billing_address_id, $billing_input_prefix, $values); if (array_key_exists('zone_id', $billingAddressArray)) { $billing_zone_id = $billingAddressArray['zone_id']; } //SHIPPING ADDRESS: get shipping address from dropdown or form (depending on selection) $shipping_zone_id = 0; if ($same_as_billing) { $shippingAddressArray = $billingAddressArray; } else { $shippingAddressArray = $this->getAddressArray($shipping_address_id, $shipping_input_prefix, $values); } if (array_key_exists('zone_id', $shippingAddressArray)) { $shipping_zone_id = $shippingAddressArray['zone_id']; } // keep the array for binding during the saveOrderInfo process $this->_orderinfoBillingAddressArray = $this->filterArrayUsingPrefix($billingAddressArray, '', 'billing_', true); $this->_orderinfoShippingAddressArray = $this->filterArrayUsingPrefix($shippingAddressArray, '', 'shipping_', true); $this->_billingAddressArray = $billingAddressArray; $this->_shippingAddressArray = $shippingAddressArray; JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); $billingAddress = JTable::getInstance('Addresses', 'CitruscartTable'); $shippingAddress = JTable::getInstance('Addresses', 'CitruscartTable'); // set the order billing address $billingAddress->bind($billingAddressArray); $billingAddress->user_id = $user_id; $billingAddress->addresstype_id = 1; if ($saveAddressesToDB && !$billing_address_id) { $clearAddressCache = true; $billingAddress->save(); if (!$billing_address_id) { $values['billing_address_id'] = $billingAddress->address_id; } } $order->setAddress($billingAddress); // set the order shipping address $shippingAddress->bind($shippingAddressArray); $shippingAddress->user_id = $user_id; $shippingAddress->addresstype_id = 2; if ($saveAddressesToDB && !$same_as_billing && !$shipping_address_id) { $clearAddressCache = true; $shippingAddress->save(); if (!$shipping_address_id) { $values['shipping_address_id'] = $shippingAddress->address_id; } } if ($clearAddressCache) { DSCModel::addIncludePath(JPATH_SITE . '/components/com_citruscart/models'); $model = DSCModel::getInstance('Addresses', 'CitruscartModel'); $model->clearCache(); } $order->setAddress($shippingAddress, 'shipping'); return $this; }
public function save($values, $options = array()) { $result = new stdClass(); $result->error = false; Citruscart::load('CitruscartHelperUser', 'helpers.user'); $userHelper = new CitruscartHelperUser(); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); $userinfo = JTable::getInstance('UserInfo', 'CitruscartTable'); $user_id = $values["user_id"]; $create_account = $values["checkout_method"] == 'register' ? true : false; $guest_checkout = $this->defines->get('guest_checkout_enabled', '1'); if ($values["checkout_method"] == "guest") { // save the real user info in the userinfo table $userinfo->user_id = $user_id; $userinfo->email = $values['email_address']; if (!$userinfo->save()) { $result->error = true; $this->setError($userinfo->getError()); } // save the billing and shipping addresses? //$this->setAddresses($submitted_values, true, true); } elseif ($values["checkout_method"] == "register") { // create a new user from billing info $details = array('email' => $values['email_address'], 'name' => $values['billing_input_first_name'] . ' ' . $values['billing_input_middle_name'] . ' ' . $values['billing_input_last_name'], 'username' => $values['email_address']); if (strlen(trim($details['name'])) == 0) { $details['name'] = JText::_('COM_CITRUSCART_USER'); } $details['password'] = $values["register-new-password"]; $details['password2'] = $values["register-new-password2"]; if (!($user = $userHelper->createNewUser($details))) { $result->error = true; //$this->setError( $user->getError() ); } else { $userHelper->login(array('username' => $user->username, 'password' => $details['password'])); $user_id = $user->id; $userinfo->load(array('user_id' => $user_id)); $userinfo->user_id = $user_id; $userinfo->first_name = $values['billing_input_first_name']; $userinfo->last_name = $values['billing_input_last_name']; $userinfo->company = $values['billing_input_company']; $userinfo->middle_name = $values['billing_input_middle_name']; $userinfo->phone_1 = $values['billing_input_phone_1']; $userinfo->email = $values['email_address']; if (!$userinfo->save()) { $result->error = true; $this->setError($userinfo->getError()); } } } $result->user_id = $user_id; $result->userinfo = $userinfo; $this->result = $result; DSCModel::addIncludePath(JPATH_SITE . '/components/com_citruscart/models'); $model = DSCModel::getInstance('Userinfo', 'CitruscartModel'); $model->clearCache(); if ($result->error) { return false; } return $result; }
public function setPayment() { $app = JFactory::getApplication(); $input = JFactory::getApplication()->input; $this->setFormat(); $session = JFactory::getSession(); $response = $this->getResponseObject(); $post = $input->getArray($_POST); $order = $this->_order; $order = $this->populateOrder(); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); $dummyaddress = JTable::getInstance('Addresses', 'CitruscartTable'); $billingAddress = unserialize($session->get('citruscart.opc.billingAddress')); $shippingAddress = unserialize($session->get('citruscart.opc.shippingAddress')); $order->setAddress($billingAddress); if (!empty($shippingAddress)) { $order->setAddress($shippingAddress, 'shipping'); } if ($shippingMethod = unserialize($session->get('citruscart.opc.shippingMethod'))) { $order->setShippingRate($shippingMethod); } if ($shippingMethod = unserialize($session->get('citruscart.opc.shippingMethod'))) { $order->setShippingRate($shippingMethod); } $order->calculateTotals(); $errorMessage = ''; if (empty($post['payment_plugin']) && $order->isPaymentRequired()) { $errorMessage = '<ul class="text-error">'; $errorMessage .= "<li>" . JText::_("COM_CITRUSCART_PLEASE_SELECT_PAYMENT_METHOD") . "</li>"; $errorMessage .= '</ul>'; $response->goto_section = 'payment'; $response->summary->html = $errorMessage; echo json_encode($response); $app->close(); } if ($order->isPaymentRequired()) { // Validate the results of the payment plugin $errorMessagesFromPlugins = ''; $dispatcher = JDispatcher::getInstance(); $results = JFactory::getApplication()->triggerEvent("onGetPaymentFormVerify", array($post['payment_plugin'], $post)); foreach ($results as $result) { if (!empty($result->error)) { $errorMessagesFromPlugins .= $result->message; } } } if (!empty($errorMessagesFromPlugins)) { $errorMessage = '<ul class="text-error">'; $errorMessage .= $errorMessagesFromPlugins; $errorMessage .= '</ul>'; $response->goto_section = 'payment'; $response->summary->id = 'opc-payment-validation'; $response->summary->html = $errorMessage; echo json_encode($response); $app->close(); } if ($order->isPaymentRequired()) { $dispatcher = JDispatcher::getInstance(); $results = JFactory::getApplication()->triggerEvent("onGetPaymentSummary", array($post['payment_plugin'], $post)); $text = ''; for ($i = 0, $count = count($results); $i < $count; $i++) { $text .= $results[$i]; } if (empty($text)) { // success summary, for now, is just the name of the plugin DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('Payment', 'CitruscartModel'); $model->setState('limit', '1'); $model->setState('filter_element', $post['payment_plugin']); if ($items = $model->getList()) { $item = $items[0]; $text = $item->name; } } $response->summary->html = $text; } else { $response->summary->html = JText::_("COM_CITRUSCART_NO_PAYMENT_NECESSARY"); } $response->summaries = array(); $summary = $this->getSummaryResponseObject(); $summary->id = 'opc-review-body'; $summary->html = $this->getOrderSummary('review'); $response->summaries[] = $summary; $response->goto_section = 'review'; echo json_encode($response); $app->close(); }
/** * Returns an array of objects, * each containing the parsed html of all articles that should be displayed * after an order is completed, * based on the defined global article and any product-, shippingmethod-, and paymentmethod-specific articles * * @param $order_id * @return array */ function getOrderArticles($order_id) { Tienda::load('TiendaArticle', 'library.article'); $articles = array(); DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = DSCModel::getInstance('OrderItems', 'TiendaModel'); $model->setState('filter_orderid', $order_id); $orderitems = $model->getList(); foreach ($orderitems as $item) { if (!empty($item->product_article)) { $articles[] = TiendaArticle::display($item->product_article); } } $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onGetOrderArticles', array($order_id, &$articles)); return $articles; }
/** * One a new order, * increase the uses count on all the ordercoupons. * * @param $order_id * @return unknown_type */ public function processOrder($order_id) { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('Ordercoupons', 'CitruscartModel'); $model->setState('filter_orderid', $order_id); if ($items = $model->getList()) { DSCTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); $coupon = DSCTable::getInstance('Coupons', 'CitruscartTable'); foreach ($items as $item) { $coupon->load(array('coupon_id' => $item->coupon_id)); $coupon->coupon_uses = $coupon->coupon_uses + 1; if (!$coupon->save()) { //JFactory::getApplication()->enqueueMessage( $coupon->getError() ); } } } }
/** * Returns an array of objects, * each containing the parsed html of all articles that should be displayed * after an order is completed, * based on the defined global article and any product-, shippingmethod-, and paymentmethod-specific articles * * @param $order_id * @return array */ function getOrderArticles($order_id) { Citruscart::load('CitruscartArticle', 'library.article'); $articles = array(); DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('OrderItems', 'CitruscartModel'); $model->setState('filter_orderid', $order_id); $orderitems = $model->getList(); foreach ($orderitems as $item) { if (!empty($item->product_article)) { $articles[] = CitruscartArticle::display($item->product_article); } } JFactory::getApplication()->triggerEvent('onGetOrderArticles', array($order_id, &$articles)); return $articles; }
/** * Method to load and return a model object. * * @access private * @param string The name of the model. * @param string Optional model prefix. * @param array Configuration array for the model. Optional. * @return mixed Model object on success; otherwise null * failure. * @since 1.5 */ function _createModel($name, $prefix = '', $config = array()) { // Clean the model name $modelName = preg_replace('/[^A-Z0-9_]/i', '', $name); $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); $result = DSCModel::getInstance($modelName, $classPrefix, $config); return $result; }
public function deleteItems($type, $oid = null) { $failed = false; $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = DSCModel::getInstance('Order' . $type, 'TiendaModel'); $model->setState('filter_orderid', $this->{$k}); if ($items = $model->getList()) { $table = $model->getTable(); $table_pk = $table->getKeyName(); foreach ($items as $item) { if (!$table->delete($item->{$table_pk})) { $errors = $table->getErrors(); if (!empty($errors)) { foreach ($errors as $key => $error) { $error = trim($error); if (!empty($error)) { $failed = true; $this->setError($error); } } } } } } if ($failed) { return false; } return true; }
/** * Run function when deleting * @see Citruscart/admin/tables/CitruscartTable#save() */ function delete($oid = null, $doReconciliation = true) { $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } if ($doReconciliation) { $pa = JTable::getInstance('ProductAttributes', 'CitruscartTable'); if ($oid) { $row = JTable::getInstance('ProductAttributeOptions', 'CitruscartTable'); $row->load($oid); $pa->load($row->productattribute_id); } else { $pa->load($this->productattribute_id); } $product_id = $pa->product_id; } if ($return = parent::delete($oid)) { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('ProductAttributeOptionValues', 'CitruscartModel'); $model->setState('filter_option', $this->{$k}); if ($items = $model->getList()) { $table = $model->getTable(); foreach ($items as $item) { if (!$table->delete($item->productattributeoptionvalue_id)) { $this->setError($table->getError()); } } } if ($doReconciliation) { Citruscart::load("CitruscartHelperProduct", 'helpers.product'); CitruscartHelperProduct::doProductQuantitiesReconciliation($product_id); } } return parent::check(); }
public function getList($refresh = false, $getEav = true, $options = array()) { static $pa, $pao; if (empty($pa)) { $pa = array(); } if (empty($pao)) { $pao = array(); } Citruscart::load("CitruscartHelperUser", 'helpers.user'); Citruscart::load('CitruscartHelperSubscription', 'helpers.subscription'); $user_helper = CitruscartHelperBase::getInstance('User'); $product_helper = CitruscartHelperBase::getInstance('Product'); if (empty($this->_list)) { JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); $items = parent::getList($refresh); // If no item in the list, return an array() if (empty($items)) { return array(); } foreach ($items as $item) { $filter_group = $user_helper->getUserGroup(JFactory::getUser()->id, $item->product_id); // at this point, ->product_price holds the default price for the product, // but the user may qualify for a discount based on volume or date, so let's get that price override $item->product_price_override = $product_helper->getPrice($item->product_id, $item->product_qty, $filter_group, JFactory::getDate()->toSql()); //checking if we do price override isset($item->product_price_override->override) ? $item->product_price_override = true : ""; if (!empty($item->product_price_override)) { $item->product_price = isset($item->product_price_override->product_price) ? $item->product_price_override->product_price : ""; } if ($item->product_recurs) { $item->recurring_price = $item->product_price; if ($item->subscription_prorated) { $result = CitruscartHelperSubscription::calculateProRatedTrial($item->subscription_prorated_date, $item->subscription_prorated_term, $item->recurring_period_unit, $item->recurring_trial_price, $item->subscription_prorated_charge); $item->product_price = $result['price']; $item->recurring_trial_price = $result['price']; $item->recurring_trial_period_interval = $result['interval']; $item->recurring_trial_period_unit = $result['unit']; $item->recurring_trial = $result['trial']; } else { if ($item->recurring_trial) { $item->product_price = $item->recurring_trial_price; } } } $item->product_parameters = new DSCParameter($item->product_params); $item->orderitem_attributes_price = '0.00000'; $item->orderitem_attributes_weight = '0.00000'; $attributes_names = array(); if (!empty($item->product_attributes)) { $item->attributes = array(); // array of each selected attribute's object $attibutes_array = explode(',', $item->product_attributes); foreach ($attibutes_array as $attrib_id) { if (empty($pao[$attrib_id])) { // load the attrib's object $pao[$attrib_id] = JTable::getInstance('ProductAttributeOptions', 'CitruscartTable'); $pao[$attrib_id]->load($attrib_id); } $table = $pao[$attrib_id]; // update the price // + or - if ($table->productattributeoption_prefix != '=') { $item->product_price = $item->product_price + floatval("{$table->productattributeoption_prefix}" . "{$table->productattributeoption_price}"); // store the attribute's price impact $item->orderitem_attributes_price = $item->orderitem_attributes_price + floatval("{$table->productattributeoption_prefix}" . "{$table->productattributeoption_price}"); //$item->product_price_override->override = true; $item->product_price_override = true; } else { // assign the product attribute price as the product price //then set the orderitem_attributes_price to 0.0000 $item->product_price = $table->productattributeoption_price; // // store the attribute's price impact $item->orderitem_attributes_price = "0.00000"; $item->product_price_override->override = false; } // update the weight // + or - if ($table->productattributeoption_prefix_weight != '=') { $item->product_weight = $item->product_weight + floatval("{$table->productattributeoption_prefix_weight}" . "{$table->productattributeoption_weight}"); // store the attribute's price impact $item->orderitem_attributes_weight = $item->orderitem_attributes_weight + floatval("{$table->productattributeoption_prefix_weight}" . "{$table->productattributeoption_weight}"); } else { // assign the product attribute price as the product price //then set the orderitem_attributes_price to 0.0000 $item->product_weight = $table->productattributeoption_weight; // // store the attribute's price impact $item->orderitem_attributes_weight = "0.00000"; } // update product values based on the selected option $m_values = DSCModel::getInstance('ProductAttributeOptionValues', 'CitruscartModel'); $m_values->setState('filter_option', $attrib_id); $list_values = $m_values->getList(); if (count($list_values)) { foreach ($list_values as $val) { switch ($val->productattributeoptionvalue_field) { case 'product_model': case 'product_sku': $field = $val->productattributeoptionvalue_field; switch ($val->productattributeoptionvalue_operator) { case 'prepend': $item->{$field} = $val->productattributeoptionvalue_value . $item->{$field}; break; case 'append': $item->{$field} = $item->{$field} . $val->productattributeoptionvalue_value; break; case 'replace': $item->{$field} = $val->productattributeoptionvalue_value; break; } break; } } } $item->orderitem_attributes_price = number_format($item->orderitem_attributes_price, '5', '.', ''); $item->orderitem_attributes_weight = number_format($item->orderitem_attributes_weight, '5', '.', ''); // store a csv of the attrib names, built by Attribute name + Attribute option name if (empty($pa[$table->productattribute_id])) { $pa[$table->productattribute_id] = JTable::getInstance('ProductAttributes', 'CitruscartTable'); $pa[$table->productattribute_id]->load($table->productattribute_id); } $atable = $pa[$table->productattribute_id]; if (!empty($atable->productattribute_id)) { $name = JText::_($atable->productattribute_name) . ': ' . JText::_($table->productattributeoption_name); $attributes_names[] = $name; } else { $attributes_names[] = JText::_($table->productattributeoption_name); } } // Generate Product Sku based upon attributes $item->product_sku = CitruscartHelperProduct::getProductSKU($item, $attibutes_array); // Could someone explain to me why this is necessary? if ($item->orderitem_attributes_price >= 0) { // formatted for storage in the DB $item->orderitem_attributes_price = "+{$item->orderitem_attributes_price}"; } } $item->attributes_names = implode(', ', $attributes_names); $this->prepareItem($item, 0, $refresh); } $this->_list = $items; } return $this->_list; }
/** * Clean the cache * * @return void * * @since 11.1 */ public function clearCacheAuxiliary() { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('ZoneRelations', 'CitruscartModel'); $model->clearCache(); }
/** * Clean the cache * * @return void * * @since 11.1 */ public function clearCacheAuxiliary() { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = DSCModel::getInstance('SubscriptionHistory', 'TiendaModel'); $model->clearCache(); }
<?php echo JText::_('COM_CITRUSCART_ADD_NEW_RELATIONSHIP'); ?> </legend> <div id="new_relationship" class="dsc-wrap dsc-table"> <div class="dsc-row"> <div class="dsc-cell"> <?php echo CitruscartSelect::relationship('', 'new_relationship_type'); ?> </div> <div class="dsc-cell"> <?php DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('ElementProduct', 'CitruscartModel'); echo $model->fetchElement('new_relationship_productid_to'); echo $model->clearElement('new_relationship_productid_to'); //<input name="new_relationship_productid_to" size="15" type="text" /> ?> <input name="new_relationship_productid_from" value="<?php echo $row->product_id; ?> " type="hidden" /> </div> <div class="dsc-cell"> <input type="button" value="<?php echo JText::_('COM_CITRUSCART_ADD'); ?> " class="btn btn-success" onclick="citruscartAddRelationship('existing_relationships', '<?php