public function init() { // get the coupon from the session and assign it to the coupon variable $session = JFactory::getSession(); // sanity check $this->code = $session->get('coupon', '', 'j2store'); if (empty($this->code)) { return false; } static $couponsets; if (!is_array($couponsets)) { $couponsets = array(); } if (!isset($couponsets[$this->code])) { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('*')->from('#__j2store_coupons')->where('coupon_code = ' . $db->q($this->code)); $db->setQuery($query); try { $row = $db->loadObject(); } catch (Exception $e) { // an error occured $row = F0FTable::getInstance('Coupon', 'J2StoreTable'); } $couponsets[$this->code] = $row; } $this->coupon = $couponsets[$this->code]; return true; }
public function update_inventory() { $app = JFactory::getApplication(); $quantity = $app->input->getInt('quantity'); $availability = $app->input->getInt('availability'); $manage_stock = $app->input->getInt('manage_stock'); $variant_id = $app->input->getInt('variant_id'); $json = array(); if ($variant_id > 0) { F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables'); $productquantities = F0FTable::getInstance('Productquantity', 'J2StoreTable')->getClone(); $productquantities->load(array('variant_id' => $variant_id)); $productquantities->variant_id = $variant_id; $productquantities->quantity = $quantity; if (!$productquantities->store()) { $json['error'] = "Problem in Save"; } $variants_table = F0FTable::getInstance('Variant', 'J2StoreTable')->getClone(); $variants_table->load($variant_id); $variants_table->availability = $availability; $variants_table->manage_stock = $manage_stock; if (!$variants_table->store()) { $json['error'] = "Problem in Save"; } } if (!$json) { $json['success'] = 'index.php?option=com_j2store&view=inventories'; } echo json_encode($json); $app->close(); }
public function save($data) { if (parent::save($data)) { if ($this->otable->j2store_geozone_id) { if (isset($data['zone_to_geo_zone']) && count($data['zone_to_geo_zone'])) { $grtable = F0FTable::getInstance('geozonerule', 'J2StoreTable'); $status = true; foreach ($data['zone_to_geo_zone'] as $georule) { $grtable->load($georule['j2store_geozonerule_id']); $georule['geozone_id'] = $this->otable->j2store_geozone_id; try { $grtable->save($georule); } catch (Exception $e) { $status = false; } if (!$status) { break; } } } else { return true; } } } else { return false; } return true; }
public function save($data) { if (parent::save($data)) { if ($this->otable->j2store_taxprofile_id) { if (isset($data['tax-to-taxrule-row']) && count($data['tax-to-taxrule-row'])) { $trTable = F0FTable::getInstance('taxrules', 'Table'); $status = true; foreach ($data['tax-to-taxrule-row'] as $taxrate) { $trTable->load($taxrate['j2store_taxrule_id']); $taxrate['taxprofile_id'] = $this->otable->j2store_taxprofile_id; try { $trTable->save($taxrate); } catch (Exception $e) { $status = false; } if (!$status) { break; } } } else { return true; } } } else { return false; } return true; }
public function save($data) { if (parent::save($data)) { if ($this->otable->j2store_option_id) { if (is_object($data)) { $data = (array) $data; } if (isset($data['option_value']) && count($data['option_value'])) { $ovTable = F0FTable::getInstance('optionvalue', 'Table'); $status = true; foreach ($data['option_value'] as $optionvalue) { $ovTable->load($optionvalue['j2store_optionvalue_id']); $optionvalue['option_id'] = $this->otable->j2store_option_id; if (!$ovTable->save($optionvalue)) { $status = false; } } } else { return true; } } } else { return false; } return true; }
public function onAfterGetItem(&$model, &$record) { //we just have the products. Get the variants $variantModel = F0FModel::getTmpInstance('Variants', 'J2StoreModel'); $variantModel->setState('product_type', $record->product_type); $app = JFactory::getApplication(); //Its a simple product. So we will have only one variant record try { $variants = $variantModel->product_id($record->j2store_product_id)->is_master(1)->getList(); $record->variants = $variants[0]; } catch (Exception $e) { $this->setError($e->getMessage()); $record->variants = F0FTable::getInstance('Variants', 'J2StoreTable'); } try { //lets load product options as well $option_model = F0FModel::getTmpInstance('ProductOptions', 'J2StoreModel')->clearState()->product_id($record->j2store_product_id)->limit(0)->limitstart(0); $view = $app->input->getCmd('view', ''); //TODO we should find an alternative method. This is a quick fix. if ($app->isSite() && $view != 'form') { $option_model->setState('parent_id', 0); } $record->product_options = $option_model->getList(); } catch (Exception $e) { $this->setError($e->getMessage()); } $registry = new JRegistry(); $registry->loadString($record->params, 'JSON'); $record->params = $registry; }
public function save($data) { $app = JFactory::getApplication(); $task = $app->input->getString('task'); if ($task == 'saveorder') { return parent::save($data); } if (parent::save($data)) { if (isset($this->otable->j2store_filtergroup_id)) { if (isset($data['filter_value']) && count($data['filter_value'])) { $ovTable = F0FTable::getInstance('filter', 'J2StoreTable'); $status = true; foreach ($data['filter_value'] as $filtervalue) { $ovTable->load($filtervalue['j2store_filter_id']); $filtervalue['group_id'] = $this->otable->j2store_filtergroup_id; if (!$ovTable->save($filtervalue)) { $status = false; } } } else { return true; } } } else { return false; } return true; }
function save() { $app = JFactory::getApplication(); $sid = $app->input->getInt('j2store_shippingmethod_id'); $values = $app->input->getArray($_POST); $model = F0FModel::getTmpInstance('ShippingMethods', 'J2StoreModel'); require_once JPATH_SITE . '/plugins/j2store/shipping_standard/shipping_standard/tables/shippingmethod.php'; $model->addIncludePath(JPATH_SITE . '/plugins/j2store/shipping_standard/shipping_standard/tables'); $this->includeCustomTables(); $table = F0FTable::getInstance('ShippingMethod', 'J2StoreTable'); $table->bind($values); try { $table->save($values); $link = $this->baseLink(); $this->messagetype = 'message'; $this->message = JText::_('J2STORE_ALL_CHANGES_SAVED'); } catch (Exception $e) { $link = $this->baseLink() . '&shippingTask=view&sid=' . $sid; $this->messagetype = 'error'; $this->message = JText::_('J2STORE_SAVE_FAILED') . $e->getMessage(); } if ($this->getTask() == 'apply') { $link = $this->baseLink() . '&shippingTask=view&sid=' . $table->j2store_shippingmethod_id; } $redirect = JRoute::_($link, false); $this->setRedirect($redirect, $this->message, $this->messagetype); }
public function onBeforeSave(&$data, &$table) { $app = JFactory::getApplication(); $addressTable = F0FTable::getInstance('Address', 'J2storeTable'); $addressTable->load($data['address_id']); $addressTable->save($data); $data['address_id'] = $addressTable->j2store_address_id; return true; }
public function getAddressById($address_id) { static $sets; if (!is_array($sets)) { $sets = array(); } if (!isset($sets[$address_id])) { $address_table = F0FTable::getInstance('Address', 'J2StoreTable'); $address_table->load($address_id); $sets[$address_id] = $address_table; } return $sets[$address_id]; }
public function init() { //get the coupon from the session and assign it to the coupon variable $session = JFactory::getSession(); $this->code = $session->get('voucher', '', 'j2store'); if (empty($this->code)) { return false; } //load the coupon $table = F0FTable::getInstance('Voucher', 'J2StoreTable'); $table->load(array('voucher_code' => $this->code)); $this->voucher = $table; return true; }
function deleteTaxRule() { $app = JFactory::getApplication(); $taxrule_id = $app->input->getInt('taxrule_id'); $taxrule = F0FTable::getInstance('taxrules', 'Table'); $response = array(); try { $taxrule->delete($taxrule_id); $response['success'] = JText::_('J2STORE_TAXRULE_DELETED_SUCCESSFULLY'); } catch (Exception $e) { $response['error'] = JText::_('J2STORE_TAXRULE_DELETE_FAILED'); } echo json_encode($response); $app->close(); }
/** * Method to delete * Geo Rule of GeoZones * @params */ function removeGeozoneRule() { $app = JFactory::getApplication(); $post = $app->input->getArray($_POST); $georule_id = $post['rule_id']; $georuleTable = F0FTable::getInstance('geozonerule', 'Table'); $json = array(); if (!$georuleTable->delete($georule_id)) { $json['msg'] = $georuleTable->getError(); } else { $json['msg'] = JText::_('J2STORE_GEORULE_DELETED_SUCCESSFULLY'); } echo json_encode($json); $app->close(); }
/** * Method to delete customer */ function delete() { // Initialise the App variables $app = JFactory::getApplication(); // Assign the get Id to the Variable $id = $app->input->getInt('id'); if ($id && $app->isAdmin()) { // store the table in the variable $address = F0FTable::getInstance('Address', 'J2StoreTable'); $address->load($id); $email = $address->email; try { $address->delete(); $msg = JText::_('J2STORE_ITEMS_DELETED'); } catch (Exception $error) { $msg = $error->getMessage(); } } $link = 'index.php?option=com_j2store&view=customer&task=viewOrder&email_id=' . $email; $this->setRedirect($link, $msg); }
public function save($data) { if (parent::save($data)) { if ($this->otable->j2store_filtergroup_id) { if (isset($data['filter_value']) && count($data['filter_value'])) { $ovTable = F0FTable::getInstance('filter', 'J2StoreTable'); $status = true; foreach ($data['filter_value'] as $filtervalue) { $ovTable->load($filtervalue['j2store_filter_id']); $filtervalue['group_id'] = $this->otable->j2store_filtergroup_id; if (!$ovTable->save($filtervalue)) { $status = false; } } } else { return true; } } } else { return false; } return true; }
public function deleteoptionvalue() { $app = JFactory::getApplication(); $option_value_id = $app->input->getInt('optionvalue_id'); $optionValue = F0FTable::getInstance('Optionvalue', 'J2StoreTable'); $json = array(); $msg_type = "success"; $msg = JText::_('J2STORE_OPTION_VALUE_DELETED_SUCCESSFULLY'); $msg_header = 'Message'; $json['success'] = true; if (!$optionValue->delete($option_value_id)) { $json['success'] = false; $msg_type = "warning"; $msg = JText::_('J2STORE_OPTION_VALUE_DELETE_ERROR'); $msg_header = 'Warning'; } $html = "<div class='alert alert-{$msg_type}'>"; $html .= "<h4 class='alert-heading'>" . $msg_header . "</h4>"; $html .= "<p>" . $msg . "</p></div>"; $json['html'] = $html; echo json_encode($json); $app->close(); }
protected function getOptions() { $options = array(); $this->value = array(); // The selected values // Deduce table name from conventional names $input = new F0FInput(); $component_prefix = ucfirst(str_replace('com_', '', $input->getString('option'))); $view_prefix = ucfirst($input->getString('view')); // Deduce name of the relation $relation_name = @F0FInflector::pluralize($this->element['name']); // todo remove silence operator // Create a relation's model instance $relation_model = F0FModel::getTmpInstance(ucfirst($relation_name), $component_prefix . 'Model'); // Get the name of key and title field $table = $relation_model->getTable(); $key_field = $table->getKeyName(); $value_field = $table->getColumnAlias('title'); // List all items from the referred table foreach ($relation_model->getItemList(true) as $value) { $options[] = JHtmlSelect::option($value->{$key_field}, $value->{$value_field}); } // Don't load selected values if item is new if ($id = $input->getInt('id')) { // Create an instance of the correct table and load this item $table = F0FTable::getInstance($view_prefix, $component_prefix . 'Table'); // Load the instance of this item, based on ID query parameter $table->load($id); // Get the relation $relation = $table->getRelations()->getMultiple($relation_name); // Add existent relation as default selected values on list foreach ($relation as $item) { $this->value[] = $item->getId(); } } return $options; }
function _prePayment($data) { $app = JFactory::getApplication(); $currency = J2Store::currency(); // Prepare the payment form $vars = new JObject(); $vars->url = JRoute::_("index.php?option=com_j2store&view=checkout"); $vars->order_id = $data['order_id']; $vars->orderpayment_id = $data['orderpayment_id']; $vars->orderpayment_type = $this->_element; F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables'); $order = F0FTable::getInstance('Order', 'J2StoreTable'); $order->load($data['orderpayment_id']); $twpg_amount = round($order->order_total, 2); $bankHandler = new Ubrir(array('shopId' => $this->params->get('twpg_id', 'PLG_J2STORE_PAYMENT_UBRIR'), 'order_id' => $data['order_id'], 'sert' => $this->params->get('twpg_sert', 'PLG_J2STORE_PAYMENT_UBRIR'), 'amount' => $twpg_amount, 'approve_url' => JURI::root() . 'plugins/j2store/payment_ubrir/payment_ubrir/tmpl/result.php?id=' . $data['order_id'], 'cancel_url' => JURI::root() . 'plugins/j2store/payment_ubrir/payment_ubrir/tmpl/result.php?id=' . $data['order_id'], 'decline_url' => JURI::root() . 'plugins/j2store/payment_ubrir/payment_ubrir/tmpl/result.php?id=' . $data['order_id'])); $response_order = $bankHandler->prepare_to_pay(); if (!empty($response_order)) { $db =& JFactory::getDBO(); $sql = " UPDATE #__j2store_orders \n\t\tSET `transaction_id` = " . $response_order->OrderID[0] . ", `transaction_details` = '" . $response_order->SessionID[0] . "'\n\t\tWHERE `order_id` = " . $data['order_id']; $db->setQuery($sql); if (!$db->query()) { exit('error_1101'); } } else { exit('error_1102'); } $out = ''; $twpg_url = $response_order->URL[0] . '?orderid=' . $response_order->OrderID[0] . '&sessionid=' . $response_order->SessionID[0]; $out .= '<p>Данный заказ необходимо оплатить одним из методов, приведенных ниже: </p> <INPUT TYPE="button" value="Оплатить Visa" onclick="document.location = \'' . $twpg_url . '\'">'; if ($this->params->get('two', 'PLG_J2STORE_PAYMENT_UBRIR') == 0) { // если активны два процессинга, то работаем еще и с Uniteller $out .= ' <INPUT TYPE="button" onclick="document.forms.uniteller.submit()" value="Оплатить MasterCard">'; include dirname(__FILE__) . "/payment_ubrir/library/include/uni_form.php"; } return $out; }
/** * Database iterator constructor. * * @param mixed $cursor The database cursor. * @param string $column An option column to use as the iterator key. * @param string $class The table class of the returned objects. * @param array $config Configuration parameters to push to the table class * * @throws InvalidArgumentException */ public function __construct($cursor, $column = null, $class, $config = array()) { // Figure out the type and prefix of the class by the class name $parts = F0FInflector::explode($class); if (count($parts) != 3) { throw new InvalidArgumentException('Invalid table name, expected a pattern like ComponentTableFoobar got ' . $class); } $this->_tableObject = F0FTable::getInstance($parts[2], ucfirst($parts[0]) . ucfirst($parts[1])); $this->cursor = $cursor; $this->class = 'stdClass'; $this->_column = $column; $this->_fetched = 0; $this->next(); }
/** * Method to generate variants * @return array Result array */ function generateVariants() { $results = array(); $app = JFactory::getApplication(); //get the product ID from POST $product_id = $this->input->getInt('product_id', 0); //generate variant combinations $variants = $this->getVariants($product_id); if (count($variants)) { //we have variants. Start creating a variant product //TODO: trigger a plugin event foreach ($variants as $variant) { unset($variantTable); $variantTable = F0FTable::getAnInstance('Variants', 'J2StoreTable')->getClone(); //first create the variant //this is not a master table $variantTable->is_master = 0; $variantTable->product_id = $product_id; //allow plugins to modify the output $app->triggerEvent('onJ2StoreBeforeVariantGeneration', array(&$variantTable)); //store the data $variantTable->store(); //allow plugins to modify the output $app->triggerEvent('onJ2StoreAfterVariantGeneration', array(&$variantTable)); //get the last stored variant id $variant_id = $variantTable->getId(); $db = JFactory::getDbo(); $columns = array('variant_id', 'product_optionvalue_ids'); $fields = array($variant_id, $db->q($variant)); unset($table); $table = F0FTable::getInstance('ProductVariantoptionvalue', 'J2StoreTable')->getClone(); if ($table->load(array('variant_id' => $variant_id))) { $query = $db->getQuery(true)->update($db->qn('#__j2store_product_variant_optionvalues'))->set($db->qn('product_optionvalue_ids') . ' = ' . $db->q($variant))->where($db->qn('variant_id') . ' = ' . $db->q($variant_id)); } else { $query = $db->getQuery(true)->insert($db->qn('#__j2store_product_variant_optionvalues'))->columns($columns)->values(implode(',', $fields)); } $db->setQuery($query)->execute(); } } return $results; }
/** * Processes the payment form * and returns HTML to be displayed to the user * generally with a success/failed message * * @param $data array * form post data * @return string HTML to display */ function _postPayment($data) { // Process the payment $app = JFactory::getApplication(); $vars = new JObject(); $html = ''; $order_id = $app->input->getString('order_id'); F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables'); $order = F0FTable::getInstance('Order', 'J2StoreTable')->getClone(); if ($order->load(array('order_id' => $order_id))) { $bank_information = $this->params->get('moneyorder_information', ''); if (JString::strlen($bank_information) > 5) { $html = '<br />'; $html .= '<strong>' . JText::_('J2STORE_MONEYORDER_INSTRUCTIONS') . '</strong>'; $html .= '<br />'; $html .= $bank_information; $order->customer_note = $order->customer_note . $html; } $order_state_id = $this->params->get('payment_status', 4); // DEFAULT: PENDING if ($order_state_id == 1) { // set order to confirmed and set the payment process complete. $order->payment_complete(); } else { // set the chosen order status and force notify customer $order->update_status($order_state_id, true); // also reduce stock $order->reduce_order_stock(); } if ($order->store()) { $order->empty_cart(); $vars->onafterpayment_text = $this->params->get('onafterpayment', ''); $html = $this->_getLayout('postpayment', $vars); // append the article with cash payment information $html .= $this->_displayArticle(); } else { $html = $this->params->get('onerrorpayment', ''); $html .= $order->getError(); } } else { // order not found $html = $this->params->get('onerrorpayment', ''); } return $html; }
/** * Method to get the field options. * * @return array The field option objects. */ protected function getOptions() { $options = array(); $this->value = array(); $value_field = $this->element['value_field'] ? (string) $this->element['value_field'] : 'title'; $input = new F0FInput(); $component = ucfirst(str_replace('com_', '', $input->getString('option'))); $view = ucfirst($input->getString('view')); $relation = F0FInflector::pluralize((string) $this->element['name']); $model = F0FModel::getTmpInstance(ucfirst($relation), $component . 'Model'); $table = $model->getTable(); $key = $table->getKeyName(); $value = $table->getColumnAlias($value_field); foreach ($model->getItemList(true) as $option) { $options[] = JHtml::_('select.option', $option->{$key}, $option->{$value}); } if ($id = F0FModel::getAnInstance($view)->getId()) { $table = F0FTable::getInstance($view, $component . 'Table'); $table->load($id); $relations = $table->getRelations()->getMultiple($relation); foreach ($relations as $item) { $this->value[] = $item->getId(); } } return $options; }
/** * Processes the sale payment * * @param array $data IPN data * @return boolean Did the IPN Validate? * @access protected */ function _processSale($data, $ipnValidationFailed = '') { /* * validate the payment data */ $errors = array(); if (!empty($ipnValidationFailed)) { $errors[] = $ipnValidationFailed; } if ($this->params->get('sandbox', 0)) { $merchant_email = trim($this->_getParam('sandbox_merchant_email')); } else { $merchant_email = trim($this->_getParam('merchant_email')); } // is the recipient correct? if (empty($data['receiver_email']) || JString::strtolower($data['receiver_email']) != JString::strtolower(trim($merchant_email))) { $errors[] = JText::_('J2STORE_PAYPAL_MESSAGE_RECEIVER_INVALID'); } $custom = $data['custom']; $custom_array = explode('|', $custom); $order_id = $custom_array[0]; // load the orderpayment record and set some values $order = F0FTable::getInstance('Order', 'J2StoreTable')->getClone(); $result = $order->load(array('order_id' => $order_id)); if ($result && !empty($order->order_id) && $order->order_id == $order_id) { $order->add_history(JText::_('J2STORE_PAYPAL_CALLBACK_IPN_RESPONSE_RECEIVED')); $order->transaction_details = $data['transaction_details']; $order->transaction_id = $data['txn_id']; $order->transaction_status = $data['payment_status']; // check the stored amount against the payment amount // check the payment status if (empty($data['payment_status']) || $data['payment_status'] != 'Completed' && $data['payment_status'] != 'Pending') { $errors[] = JText::sprintf('J2STORE_PAYPAL_MESSAGE_STATUS_INVALID', @$data['payment_status']); } // save the data if (!$order->store()) { $errors[] = $order->getError(); } // set the order's new status if (count($errors)) { // mark as failed $order->update_status(3); } elseif (strtoupper($data['payment_status']) == 'PENDING') { // set order to pending. Also notify the customer that it is pending $order->update_status(4, true); // reduce the order stock. Because the status is pending. $order->reduce_order_stock(); } elseif (strtoupper($data['payment_status']) == 'COMPLETED') { $order->payment_complete(); } //clear cart $order->empty_cart(); } return count($errors) ? implode("\n", $errors) : ''; }
/** * Returns a F0FDatabaseIterator based on a given relation * * @param array $relation Indexed array holding relation definition. * tableClass => name of the related table class * localKey => name of the local key * remoteKey => name of the remote key * pivotTable => name of the pivot table (optional) * theirPivotKey => name of the remote key in the pivot table (mandatory if pivotTable is set) * ourPivotKey => name of our key in the pivot table (mandatory if pivotTable is set) * * @return F0FDatabaseIterator * * @throws RuntimeException * @throws InvalidArgumentException */ protected function getIteratorFromRelation($relation) { // Sanity checks if (!isset($relation['tableClass']) || !isset($relation['remoteKey']) || !isset($relation['localKey']) || !$relation['tableClass'] || !$relation['remoteKey'] || !$relation['localKey']) { throw new InvalidArgumentException('Missing array index for the ' . __METHOD__ . ' method. Please check method signature', 500); } if (array_key_exists('pivotTable', $relation)) { if (!isset($relation['theirPivotKey']) || !isset($relation['ourPivotKey']) || !$relation['pivotTable'] || !$relation['theirPivotKey'] || !$relation['ourPivotKey']) { throw new InvalidArgumentException('Missing array index for the ' . __METHOD__ . ' method. Please check method signature', 500); } } // Get a table object from the table class name $tableClass = $relation['tableClass']; $tableClassParts = F0FInflector::explode($tableClass); if (count($tableClassParts) < 3) { throw new InvalidArgumentException('Invalid table class named. It should be something like FooTableBar'); } $table = F0FTable::getInstance($tableClassParts[2], ucfirst($tableClassParts[0]) . ucfirst($tableClassParts[1])); // Get the table name $tableName = $table->getTableName(); // Get the remote and local key names $remoteKey = $relation['remoteKey']; $localKey = $relation['localKey']; // Get the local key's value $value = $this->table->{$localKey}; // If there's no value for the primary key, let's stop here if (!$value) { throw new RuntimeException('Missing value for the primary key of the table ' . $this->table->getTableName(), 500); } // This is required to prevent one relation from killing the db cursor used in a different relation... $oldDb = $this->table->getDbo(); $oldDb->disconnect(); // YES, WE DO NEED TO DISCONNECT BEFORE WE CLONE THE DB OBJECT. ARGH! $db = clone $oldDb; // Begin the query $query = $db->getQuery(true)->select('*')->from($db->qn($tableName)); // Do we have a pivot table? $hasPivot = array_key_exists('pivotTable', $relation); // If we don't have pivot it's a straightforward query if (!$hasPivot) { $query->where($db->qn($remoteKey) . ' = ' . $db->q($value)); } else { $subQuery = $db->getQuery(true)->select($db->qn($relation['theirPivotKey']))->from($db->qn($relation['pivotTable']))->where($db->qn($relation['ourPivotKey']) . ' = ' . $db->q($value)); $query->where($db->qn($remoteKey) . ' IN (' . $subQuery . ')'); } $db->setQuery($query); $cursor = $db->execute(); $iterator = F0FDatabaseIterator::getIterator($db->name, $cursor, null, $tableClass); return $iterator; }
public function validate_files($files = array()) { $app = JFactory::getApplication(); $json = array(); if (count($files) < 1) { $files = $app->input->files->get('file'); } $upload_result = $this->uploadFile($files); if ($upload_result == false) { $json['error'] = $this->getError(); } else { $upload = F0FTable::getInstance('Upload', 'J2StoreTable'); $upload->reset(); $upload->j2store_upload_id = null; $jdate = new JDate(); $upload_result['created_by'] = JFactory::getUser()->id; $upload_result['created_on'] = $jdate->toSql(); $upload_result['enabled'] = 1; if (!$upload->save($upload_result)) { $json['error'] = JText::sprintf('J2STORE_UPLOAD_ERR_GENERIC_ERROR'); } } if (!$json) { $json['name'] = $upload_result['original_name']; $json['code'] = $upload_result['mangled_name']; $json['success'] = JText::_('J2STORE_UPLOAD_SUCCESSFUL'); } return $json; }
?> </h3> <div class="myprofile-address-addnew"> <?php echo J2StorePopup::popupAdvanced('index.php?option=com_j2store&view=myprofile&task=editAddress&layout=address&tmpl=component&address_id=', JText::_('J2STORE_ADD'), array('update' => true, 'class' => 'btn btn-success', 'width' => 800, 'height' => 600)); ?> </div> <hr> <ul class="j2store-myprofile-address-list"> <?php if ($this->orderinfos && !empty($this->orderinfos)) { foreach ($this->orderinfos as $orderinfo) { ?> <?php $addressTable = F0FTable::getInstance('Address', 'J2StoreTable'); $addressTable->load($orderinfo->j2store_address_id); $fields = $this->fieldClass->getFields($addressTable->type, $addressTable, 'address'); ?> <li id="j2store-address-tr-<?php echo $orderinfo->j2store_address_id; ?> " class="j2store-myprofile-address-single-list well" > <ul class="j2store-myprofile-address-controls inline pull-right"> <li class="myprofile-address-control-edit"> <?php echo J2StorePopup::popup('index.php?option=com_j2store&view=myprofile&task=editAddress&layout=address&tmpl=component&address_id=' . $orderinfo->j2store_address_id, JText::_('J2STORE_EDIT'), array('update' => true, 'width' => 800, 'height' => 500)); ?> </li> <li class="myprofile-address-control-delete"> <a href="<?php
</th> <th><?php echo JText::_('J2STORE_ORDER_STATUS'); ?> </th> <th><?php echo JText::_('J2STORE_ACTIONS'); ?> </th> </thead> <tbody> <?php foreach ($this->orders as $item) { ?> <?php $order = F0FTable::getInstance('Order', 'J2StoreTable'); $order->load(array('order_id' => $item->order_id)); ?> <tr> <td><?php $tz = JFactory::getConfig()->get('offset'); $date = JFactory::getDate($item->created_on, $tz); $order_date = $date->format(J2Store::config()->get('date_format', JText::_('DATE_FORMAT_LC1')), true); echo $order_date; ?> </td> <td><?php if ($item->invoice_number && !empty($item->invoice_prefix)) { $invoice = $item->invoice_prefix . $item->invoice_number; } else { $invoice = $item->j2store_order_id;
<span class="cart-product-name"> <?php echo $item->orderitem_name; ?> </span> <br /> <?php if (isset($item->orderitemattributes)) { ?> <span class="cart-item-options"> <?php foreach ($item->orderitemattributes as $attribute) { if ($attribute->orderitemattribute_type == 'file') { unset($table); $table = F0FTable::getInstance('Upload', 'J2StoreTable')->getClone(); if ($table->load(array('mangled_name' => $attribute->orderitemattribute_value))) { $attribute_value = $table->original_name; } } else { $attribute_value = $attribute->orderitemattribute_value; } ?> <small> - <?php echo JText::_($attribute->orderitemattribute_name); ?> : <?php echo $attribute_value; ?> </small>
public function printShipping() { $app = JFactory::getApplication(); $order_id = $this->input->getString('order_id'); $view = $this->getThisView(); if ($model = $this->getThisModel()) { // Push the model into the view (as default) $view->setModel($model, true); } $order = F0FTable::getInstance('Order', 'J2StoreTable'); $order->load(array('order_id' => $order_id)); $orderinfo = F0FTable::getAnInstance('Orderinfo', 'J2StoreTable'); $orderinfo->load(array('order_id' => $order_id)); $error = false; $view->assign('orderinfo', $orderinfo); $view->assign('item', $order); $view->assign('params', J2Store::config()); $view->assign('error', $error); $view->setLayout('print_shipping'); $view->display(); }
public function runIndexes($table) { //first get all the variants for the product $variants = F0FModel::getTmpInstance('variants', 'J2StoreModel')->product_id($table->j2store_product_id)->is_master(0)->getList(); $min_price = null; $max_price = null; foreach ($variants as $variant) { // Skip non-priced variations if ($variant->price === '' || $variant->price == 0) { continue; } // Find min price if (is_null($min_price) || $variant->price < $min_price) { $min_price = $variant->price; } // Find max price if ($variant->price > $max_price) { $max_price = $variant->price; } } //load the price index table and set the min - max price $db = JFactory::getDbo(); $values = array(); $product_id = $table->j2store_product_id; $values['product_id'] = $product_id; $values['min_price'] = $min_price; $values['max_price'] = $max_price; $price_index = F0FTable::getInstance('ProductPriceIndex', 'J2StoreTable'); $object = (object) $values; if ($price_index->load($table->j2store_product_id)) { $db->updateObject('#__j2store_productprice_index', $object, 'product_id'); } else { $db->insertObject('#__j2store_productprice_index', $object); } }