Example #1
0
 /**
  * Generate and return the address label
  * @param array
  * @return string
  */
 public function renderLabel($arrAddress)
 {
     $objAddress = new \Isotope\Model\Address();
     $objAddress->setRow($arrAddress);
     $strBuffer = $objAddress->generateHtml();
     $strBuffer .= '<div style="color:#b3b3b3;margin-top:8px">' . $GLOBALS['TL_LANG']['tl_iso_address']['store_id'][0] . ' ' . $arrAddress['store_id'];
     if ($arrAddress['isDefaultBilling']) {
         $strBuffer .= ', ' . $GLOBALS['TL_LANG']['tl_iso_address']['isDefaultBilling'][0];
     }
     if ($arrAddress['isDefaultShipping']) {
         $strBuffer .= ', ' . $GLOBALS['TL_LANG']['tl_iso_address']['isDefaultShipping'][0];
     }
     $strBuffer .= '</div>';
     return $strBuffer;
 }
Example #2
0
 /**
  * Reset all default checkboxes when setting a new address as default
  * @param mixed
  * @param object
  * @return mixed
  * @link http://www.contao.org/callback.html#save_callback
  */
 public function updateDefault($varValue, $dc)
 {
     if ($varValue == '1' && $dc->activeRecord->{$dc->field} != $varValue) {
         \Database::getInstance()->prepare("\n                UPDATE " . Address::getTable() . " SET {$dc->field}='' WHERE pid=? AND ptable=? AND store_id=?\n            ")->execute($dc->activeRecord->pid, $dc->activeRecord->ptable, $dc->activeRecord->store_id);
     }
     return $varValue;
 }
 /**
  * save_callback to sort attribute wizard fields by legend
  *
  * @param mixed $varValue
  *
  * @return string
  */
 public function save($varValue)
 {
     $this->loadDataContainer(\Isotope\Model\Address::getTable());
     $arrFields = deserialize($varValue);
     if (empty($arrFields) || !is_array($arrFields)) {
         return $varValue;
     }
     $arrValues = array();
     foreach (array_values($arrFields) as $pos => $arrConfig) {
         $arrConfig['position'] = $pos;
         $arrValues[$arrConfig['name']] = $arrConfig;
     }
     return serialize($arrValues);
 }
Example #4
0
 /**
  * Get shipping address or create if none exists
  * @return  Address
  */
 public function getShippingAddress()
 {
     $objAddress = parent::getShippingAddress();
     if (null === $objAddress && FE_USER_LOGGED_IN === true) {
         $objAddress = Address::findDefaultShippingForMember(\FrontendUser::getInstance()->id);
         if (null === $objAddress) {
             $objAddress = Address::createForMember(\FrontendUser::getInstance()->id, Isotope::getConfig()->getShippingFields());
         }
     }
     if (null === $objAddress) {
         $objAddress = new Address();
         $objAddress->country = Isotope::getConfig()->shipping_country;
     }
     return $objAddress;
 }
Example #5
0
 /**
  * Get shipping address or create if none exists
  *
  * @return Address
  */
 public function getShippingAddress()
 {
     $objAddress = parent::getShippingAddress();
     // Try to load the default member address
     if (null === $objAddress && FE_USER_LOGGED_IN === true) {
         $objAddress = Address::findDefaultShippingForMember(\FrontendUser::getInstance()->id);
     }
     // Try to load the default collection address
     if (null === $objAddress) {
         $objAddress = Address::findDefaultShippingForProductCollection($this->id);
     }
     // Last option: create a new address, including member data if available
     if (null === $objAddress) {
         $objAddress = Address::createForProductCollection($this, Isotope::getConfig()->getShippingFields(), false, true);
     }
     return $objAddress;
 }
<?php

/**
 * Isotope eCommerce for Contao Open Source CMS
 *
 * Copyright (C) 2009-2014 terminal42 gmbh & Isotope eCommerce Workgroup
 *
 * @package    Isotope
 * @link       http://isotopeecommerce.org
 * @license    http://opensource.org/licenses/lgpl-3.0.html
 */
/**
 * Load tl_iso_product data container and language files
 */
$this->loadDataContainer('tl_iso_product');
\System::loadLanguageFile('tl_iso_product');
/**
 * Table tl_iso_product_collection
 */
$GLOBALS['TL_DCA']['tl_iso_product_collection'] = array('config' => array('dataContainer' => 'Table', 'enableVersioning' => false, 'ctable' => array(\Isotope\Model\ProductCollectionItem::getTable(), \Isotope\Model\ProductCollectionSurcharge::getTable(), \Isotope\Model\Address::getTable()), 'closed' => true, 'notDeletable' => \Input::get('act') == 'select', 'onload_callback' => array(array('Isotope\\Backend\\ProductCollection\\Callback', 'checkPermission')), 'onsubmit_callback' => array(array('Isotope\\Backend\\ProductCollection\\Callback', 'executeSaveHook')), 'sql' => array('keys' => array('id' => 'primary', 'uniqid' => 'unique', 'member,store_id,type' => 'index', 'uniqid,store_id,type' => 'index', 'source_collection_id,type' => 'index'))), 'list' => array('sorting' => array('mode' => 2, 'fields' => array('locked DESC'), 'panelLayout' => 'filter;sort,search,limit', 'filter' => array(array('type=?', 'order'), array('order_status>?', '0'), array("locked!=?", ''))), 'label' => array('fields' => array('document_number', 'locked', 'billing_address_id', 'total', 'order_status'), 'showColumns' => true, 'label_callback' => array('Isotope\\Backend\\ProductCollection\\Callback', 'getOrderLabel')), 'global_operations' => array('all' => array('label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'href' => 'act=select', 'class' => 'header_edit_all', 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"')), 'operations' => array('edit' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['edit'], 'href' => 'act=edit', 'icon' => 'edit.gif'), 'delete' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['delete'], 'href' => 'act=delete', 'icon' => 'delete.gif', 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'), 'show' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['show'], 'href' => 'act=show', 'icon' => 'show.gif'), 'payment' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['payment'], 'href' => 'key=payment', 'icon' => 'system/modules/isotope/assets/images/money-coin.png', 'button_callback' => array('\\Isotope\\Backend\\ProductCollection\\Callback', 'paymentButton')), 'shipping' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['shipping'], 'href' => 'key=shipping', 'icon' => 'system/modules/isotope/assets/images/box-label.png', 'button_callback' => array('\\Isotope\\Backend\\ProductCollection\\Callback', 'shippingButton')), 'print_document' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['print_document'], 'href' => 'key=print_document', 'icon' => 'system/modules/isotope/assets/images/document-pdf-text.png'))), 'palettes' => array('default' => '{status_legend},order_status,date_paid,date_shipped;{details_legend},details,notes;{email_legend:hide},email_data;{billing_address_legend:hide},billing_address_data;{shipping_address_legend:hide},shipping_address_data'), 'fields' => array('id' => array('sql' => "int(10) unsigned NOT NULL auto_increment"), 'tstamp' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'type' => array('eval' => array('doNotShow' => true), 'sql' => "varchar(32) NOT NULL default ''"), 'member' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['member'], 'foreignKey' => "tl_member.CONCAT(firstname, ' ', lastname)", 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'locked' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['locked'], 'flag' => 8, 'filter' => true, 'sorting' => true, 'eval' => array('rgxp' => 'date'), 'sql' => "varchar(10) NOT NULL default ''"), 'store_id' => array('eval' => array('doNotShow' => true), 'sql' => "int(2) unsigned NOT NULL default '0'"), 'settings' => array('eval' => array('doNotShow' => true), 'sql' => "blob NULL"), 'checkout_info' => array('eval' => array('doNotShow' => true), 'sql' => "blob NULL"), 'payment_data' => array('eval' => array('doNotShow' => true), 'sql' => "blob NULL"), 'shipping_data' => array('eval' => array('doNotShow' => true), 'sql' => "blob NULL"), 'source_collection_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['source_collection_id'], 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy', 'table' => 'tl_iso_product_collection')), 'document_number' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['document_number'], 'search' => true, 'sorting' => true, 'sql' => "varchar(64) NOT NULL default ''"), 'uniqid' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['uniqid'], 'search' => true, 'sql' => "varchar(64) NULL"), 'order_status' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['order_status'], 'exclude' => true, 'filter' => true, 'sorting' => true, 'inputType' => 'select', 'foreignKey' => \Isotope\Model\OrderStatus::getTable() . '.name', 'options_callback' => array('\\Isotope\\Backend', 'getOrderStatus'), 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy'), 'save_callback' => array(array('Isotope\\Backend\\ProductCollection\\Callback', 'updateOrderStatus'))), 'date_paid' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['date_paid'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'datim', 'datepicker' => method_exists($this, 'getDatePickerString') ? $this->getDatePickerString() : true, 'tl_class' => 'w50 wizard'), 'sql' => "varchar(10) NOT NULL default ''"), 'date_shipped' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['date_shipped'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'date', 'datepicker' => method_exists($this, 'getDatePickerString') ? $this->getDatePickerString() : true, 'tl_class' => 'w50 wizard'), 'sql' => "varchar(10) NOT NULL default ''"), 'config_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['config_id'], 'foreignKey' => \Isotope\Model\Config::getTable() . '.name', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'payment_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['payment_id'], 'filter' => true, 'foreignKey' => \Isotope\Model\Payment::getTable() . '.name', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'shipping_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['shipping_id'], 'filter' => true, 'foreignKey' => \Isotope\Model\Shipping::getTable() . '.name', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'billing_address_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['billing_address_id'], 'foreignKey' => \Isotope\Model\Address::getTable() . '.label', 'eval' => array('doNotShow' => true), 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'shipping_address_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['shipping_address_id'], 'foreignKey' => \Isotope\Model\Address::getTable() . '.label', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'details' => array('input_field_callback' => array('Isotope\\Backend\\ProductCollection\\Callback', 'generateOrderDetails'), 'eval' => array('doNotShow' => true)), 'subtotal' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['subtotal'], 'sql' => "decimal(12,2) NOT NULL default '0.00'"), 'tax_free_subtotal' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['tax_free_subtotal'], 'sql' => "decimal(12,2) NOT NULL default '0.00'"), 'total' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['total'], 'sorting' => true, 'sql' => "decimal(12,2) NOT NULL default '0.00'"), 'tax_free_total' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['tax_free_total'], 'sql' => "decimal(12,2) NOT NULL default '0.00'"), 'currency' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['currency'], 'sql' => "varchar(4) NOT NULL default ''"), 'language' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['language'], 'sql' => "varchar(5) NOT NULL default ''"), 'notes' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['notes'], 'exclude' => true, 'inputType' => 'textarea', 'eval' => array('style' => 'height:80px;'), 'sql' => "text NULL"), 'email_data' => array('input_field_callback' => array('Isotope\\Backend\\ProductCollection\\Callback', 'generateEmailData'), 'eval' => array('doNotShow' => true)), 'billing_address_data' => array('input_field_callback' => array('Isotope\\Backend\\ProductCollection\\Callback', 'generateBillingAddressData'), 'eval' => array('doNotShow' => true)), 'shipping_address_data' => array('input_field_callback' => array('Isotope\\Backend\\ProductCollection\\Callback', 'generateShippingAddressData'), 'eval' => array('doNotShow' => true))));
Example #7
0
 /**
  * Also delete child table records when dropping this collection
  * @return integer
  */
 public function delete()
 {
     $this->ensureNotLocked();
     // !HOOK: additional functionality when deleting a collection
     if (isset($GLOBALS['ISO_HOOKS']['deleteCollection']) && is_array($GLOBALS['ISO_HOOKS']['deleteCollection'])) {
         foreach ($GLOBALS['ISO_HOOKS']['deleteCollection'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $blnRemove = $objCallback->{$callback}[1]($this);
             if ($blnRemove === false) {
                 return 0;
             }
         }
     }
     $intPid = $this->id;
     $intAffectedRows = parent::delete();
     if ($intAffectedRows > 0 && $intPid > 0) {
         \Database::getInstance()->query("DELETE FROM " . \Isotope\Model\ProductCollectionItem::getTable() . " WHERE pid={$intPid}");
         \Database::getInstance()->query("DELETE FROM " . \Isotope\Model\Address::getTable() . " WHERE ptable='" . static::$strTable . "' AND pid={$intPid}");
     }
     $this->arrCache = array();
     $this->arrItems = null;
     $this->arrSurcharges = null;
     return $intAffectedRows;
 }
Example #8
0
 /**
  * Delete the given address and make sure it belongs to the current frontend user
  * @param integer
  * @return void
  */
 protected function delete($intAddressId)
 {
     if (($objAddress = Address::findOneForMember($intAddressId, \FrontendUser::getInstance()->id)) !== null) {
         $objAddress->delete();
     }
     global $objPage;
     \Controller::redirect(\Controller::generateFrontendUrl($objPage->row()));
 }
Example #9
0
 /**
  * Mark existing addresses as not default if the new address is default
  *
  * @param Address $objAddress
  */
 protected function updateDefaultAddress(Address $objAddress)
 {
     $arrSet = array();
     if ($objAddress->isDefaultBilling) {
         $arrSet['isDefaultBilling'] = '';
     }
     if ($objAddress->isDefaultShipping) {
         $arrSet['isDefaultShipping'] = '';
     }
     if (!empty($arrSet)) {
         // @todo restore foratting when #6623 is fixed in Contao core
         \Database::getInstance()->prepare("UPDATE " . $objAddress->getTable() . " %s WHERE pid=? AND ptable=? AND store_id=? AND id!=?")->set($arrSet)->execute($this->member, \MemberModel::getTable(), $this->store_id, $objAddress->id);
     }
 }
Example #10
0
 /**
  * Returns an address model for the shop configuration address data.
  *
  * @return Address
  */
 public function getOwnerAddress()
 {
     $address = new Address();
     $address->company = $this->company;
     $address->firstname = $this->firstname;
     $address->lastname = $this->lastname;
     $address->street_1 = $this->street_1;
     $address->street_2 = $this->street_2;
     $address->street_3 = $this->street_3;
     $address->postal = $this->postal;
     $address->city = $this->city;
     $address->subdivision = $this->subdivision;
     $address->country = $this->country;
     $address->email = $this->email;
     $address->phone = $this->phone;
     $address->vat_no = $this->vat_no;
     $address->preventSaving();
     return $address;
 }
Example #11
0
    /**
     * Generate address details amd return it as string
     * @param   Address
     * @return  string
     */
    protected function generateAddressData(Address $objAddress = null)
    {
        if (null === $objAddress) {
            return '<div class="tl_gerror">No address data available.</div>';
        }
        \System::loadLanguageFile($objAddress->getTable());
        $this->loadDataContainer($objAddress->getTable());
        $strBuffer = '
<div>
<table cellpadding="0" cellspacing="0" class="tl_show" summary="Table lists all details of an entry" style="width:650px">
  <tbody>';
        $i = 0;
        foreach ($GLOBALS['TL_DCA'][$objAddress->getTable()]['fields'] as $k => $v) {
            if (!isset($objAddress->{$k})) {
                continue;
            }
            $v = $objAddress->{$k};
            $strClass = ++$i % 2 ? '' : ' class="tl_bg"';
            $strBuffer .= '
  <tr>
    <td' . $strClass . ' style="vertical-align:top"><span class="tl_label">' . Format::dcaLabel($objAddress->getTable(), $k) . ': </span></td>
    <td' . $strClass . '>' . Format::dcaValue($objAddress->getTable(), $k, $v) . '</td>
  </tr>';
        }
        $strBuffer .= '
</tbody></table>
</div>';
        return $strBuffer;
    }
Example #12
0
<?php

/**
 * Isotope eCommerce for Contao Open Source CMS
 *
 * Copyright (C) 2009-2014 terminal42 gmbh & Isotope eCommerce Workgroup
 *
 * @package    Isotope
 * @link       http://isotopeecommerce.org
 * @license    http://opensource.org/licenses/lgpl-3.0.html
 */
/**
 * Add a child table to tl_member
 */
$GLOBALS['TL_DCA']['tl_member']['config']['ctable'][] = \Isotope\Model\Address::getTable();
$GLOBALS['TL_DCA']['tl_member']['config']['ondelete_callback'][] = array('\\Isotope\\Backend\\Member\\Callback', 'deleteMemberCart');
/**
 * Add a global operation to tl_member
 */
$GLOBALS['TL_DCA']['tl_member']['list']['operations']['address_book'] = array('label' => &$GLOBALS['TL_LANG']['tl_member']['address_book'], 'href' => 'table=' . \Isotope\Model\Address::getTable(), 'icon' => 'system/modules/isotope/assets/images/cards-address.png');
/**
 * Force the "country" field to be mandatory
 */
$GLOBALS['TL_DCA']['tl_member']['fields']['country']['eval']['mandatory'] = true;
 /**
  * Get default address for this collection and address type
  *
  * @return AddressModel
  */
 protected function getDefaultAddress()
 {
     $objAddress = AddressModel::findDefaultShippingForProductCollection(Isotope::getCart()->id);
     if (null === $objAddress) {
         $objAddress = AddressModel::createForProductCollection(Isotope::getCart(), Isotope::getConfig()->getShippingFields(), false, true);
     }
     return $objAddress;
 }
 protected function processForm()
 {
     // get a product collection (aka cart)
     global $objPage;
     $objCart = new Cart();
     // Can't call the individual rows here, it would trigger markModified and a save()
     $objCart->setRow(array_merge($objCart->row(), array('tstamp' => time(), 'member' => 0, 'uniqid' => null, 'config_id' => $this->iso_config_id, 'store_id' => (int) \PageModel::findByPk($objPage->rootId)->iso_store_id)));
     $objSubmission = $this->getSubmission(false);
     // add products to cart
     foreach ($this->arrProducts as $arrProduct) {
         $strProduct = 'product_' . $arrProduct['product']->id;
         $strQuantity = 'quantity_' . $arrProduct['product']->id;
         if (($this->getProductCount() > 1 || $this->getTypeCount() > 1) && !$objSubmission->{$strProduct}) {
             continue;
         }
         if (!$objCart->addProduct($arrProduct['product'], $arrProduct['useQuantity'] ? $objSubmission->{$strQuantity} : 1)) {
             $this->transformIsotopeErrorMessages();
             return;
         }
     }
     $objCart->save();
     $objOrder = $objCart->getDraftOrder();
     // temporarily override the cart for generating the reviews...
     $objCartTmp = Isotope::getCart();
     Isotope::setCart($objCart);
     // create steps
     $arrSteps = array();
     $arrCheckoutInfo = array();
     // billing address
     $objBillingAddress = new Address();
     foreach ($this->arrBillingAddressFields as $strName) {
         $objBillingAddress->{$strName} = $objSubmission->{$strName};
     }
     $objBillingAddress->save();
     $objOrder->setBillingAddress($objBillingAddress);
     $objBillingAddressStep = new BillingAddress($this->objCheckoutModule);
     $arrSteps[] = $objBillingAddressStep;
     $arrCheckoutInfo['billing_address'] = $objBillingAddressStep->review()['billing_address'];
     // shipping address
     $objShippingAddress = new Address();
     // standard isotope handling for distinguishing between the address types:
     // -> if only a billing address is available, it's also the shipping address
     foreach ($objSubmission->shippingaddress ? $this->arrShippingAddressFields : $this->arrBillingAddressFields as $strName) {
         $objShippingAddress->{str_replace('shippingaddress_', '', $strName)} = $objSubmission->{$objSubmission->shippingaddress ? $strName : str_replace('shippingaddress_', 'billingaddress_', $strName)};
     }
     $objShippingAddress->save();
     //        $objOrder->setShippingAddress($objShippingAddress);
     //        $objShippingAddressStep              = new ShippingAddress($this->objCheckoutModule);
     //        $arrSteps[]                          = $objShippingAddressStep;
     //        $arrCheckoutInfo['shipping_address'] = $objShippingAddressStep->review()['shipping_address'];
     // add shipping method
     $objIsotopeShipping = Flat::findByPk($this->iso_shipping_modules);
     $objOrder->setShippingMethod($objIsotopeShipping);
     $objShippingMethodStep = new ShippingMethod($this->objCheckoutModule);
     $arrSteps[] = $objShippingMethodStep;
     $arrCheckoutInfo['shipping_method'] = $objShippingMethodStep->review()['shipping_method'];
     // add all the checkout info to the order
     $objOrder->checkout_info = $arrCheckoutInfo;
     $objOrder->notes = $objSubmission->notes;
     //... restore the former cart again
     Isotope::setCart($objCartTmp);
     $objOrder->nc_notification = $this->nc_notification;
     $objOrder->email_data = $this->getNotificationTokensFromSteps($arrSteps, $objOrder);
     // !HOOK: pre-process checkout
     if (isset($GLOBALS['ISO_HOOKS']['preCheckout']) && is_array($GLOBALS['ISO_HOOKS']['preCheckout'])) {
         foreach ($GLOBALS['ISO_HOOKS']['preCheckout'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             if ($objCallback->{$callback}[1]($objOrder, $this->objCheckoutModule) === false) {
                 \System::log('Callback ' . $callback[0] . '::' . $callback[1] . '() cancelled checkout for Order ID ' . $this->id, __METHOD__, TL_ERROR);
                 $this->objCheckoutModule->redirectToStep('failed');
             }
         }
     }
     $objOrder->lock();
     $objOrder->checkout();
     $objOrder->complete();
     if (is_array($this->dca['config']['onsubmit_callback'])) {
         foreach ($this->dca['config']['onsubmit_callback'] as $key => $callback) {
             if ($callback[0] == 'Isotope\\Backend\\ProductCollection\\Callback' && $callback[1] == 'executeSaveHook') {
                 unset($this->dca['config']['onsubmit_callback'][$key]);
                 break;
             }
         }
     }
     $this->transformIsotopeErrorMessages();
     parent::processForm();
 }
Example #15
0
 /**
  * Get default address for this collection and address type
  *
  * @param bool $useBilling
  *
  * @return Address
  */
 private function getDefaultAddress($useBilling)
 {
     $objAddress = null;
     $intCart = Isotope::getCart()->id;
     if ($intCart > 0) {
         if ($useBilling) {
             $objAddress = Address::findDefaultBillingForProductCollection($intCart);
         } else {
             $objAddress = Address::findDefaultShippingForProductCollection($intCart);
         }
     }
     if (null === $objAddress) {
         $objAddress = Address::createForProductCollection(Isotope::getCart(), $useBilling ? Isotope::getConfig()->getBillingFields() : Isotope::getConfig()->getShippingFields(), $useBilling, !$useBilling);
     }
     return $objAddress;
 }
Example #16
0
 /**
  * Get addresses for the current member
  * @return  array
  */
 protected function getAddresses()
 {
     $objAddresses = AddressModel::findForMember(\FrontendUser::getInstance()->id, array('order' => 'isDefaultBilling DESC, isDefaultShipping DESC'));
     return null === $objAddresses ? array() : $objAddresses->getModels();
 }
Example #17
0
 /**
  * Create a new address for a member and automatically set default properties
  * @param   int
  * @param   array|null
  * @return  Address
  */
 public static function createForMember($intMember, $arrFill = null)
 {
     $objAddress = new Address();
     $arrData = array('pid' => $intMember, 'ptable' => 'tl_member', 'tstamp' => time(), 'store_id' => Isotope::getCart()->store_id);
     if (!empty($arrFill) && is_array($arrFill) && ($objMember = \MemberModel::findByPk($intMember)) !== null) {
         $arrData = array_intersect_key(array_merge($objMember->row(), $arrData, array('street_1' => $objMember->street, 'subdivision' => strtoupper($objMember->country . '-' . $objMember->state))), array_flip($arrFill));
     }
     $objAddress->setRow($arrData);
     return $objAddress;
 }
Example #18
0
\Isotope\Model\Attribute::registerModelType('upload', 'Isotope\\Model\\Attribute\\Upload');
/**
 * Notification Center notification types
 */
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients'] = array('recipient_email');
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['attachment_tokens'] = array('form_*', 'document');
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text'] = array('uniqid', 'order_status', 'order_status_old', 'order_status_id', 'order_status_id_old', 'recipient_email', 'order_id', 'order_items', 'order_products', 'order_subtotal', 'order_total', 'document_number', 'cart_html', 'cart_text', 'document', 'billing_address', 'billing_address_*', 'shipping_address', 'shipping_address_*', 'form_*', 'payment_id', 'payment_label', 'payment_note', 'shipping_id', 'shipping_label', 'shipping_note', 'config_*', 'member_*');
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_subject'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text'];
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_html'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text'];
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_replyTo'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients'];
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_recipient_cc'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients'];
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_recipient_bcc'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients'];
/**
 * Models
 */
$GLOBALS['TL_MODELS'][\Isotope\Model\Address::getTable()] = 'Isotope\\Model\\Address';
$GLOBALS['TL_MODELS'][\Isotope\Model\Attribute::getTable()] = 'Isotope\\Model\\Attribute';
$GLOBALS['TL_MODELS'][\Isotope\Model\BasePrice::getTable()] = 'Isotope\\Model\\BasePrice';
$GLOBALS['TL_MODELS'][\Isotope\Model\Config::getTable()] = 'Isotope\\Model\\Config';
$GLOBALS['TL_MODELS'][\Isotope\Model\Document::getTable()] = 'Isotope\\Model\\Document';
$GLOBALS['TL_MODELS'][\Isotope\Model\Download::getTable()] = 'Isotope\\Model\\Download';
$GLOBALS['TL_MODELS'][\Isotope\Model\Gallery::getTable()] = 'Isotope\\Model\\Gallery';
$GLOBALS['TL_MODELS'][\Isotope\Model\Group::getTable()] = 'Isotope\\Model\\Group';
$GLOBALS['TL_MODELS'][\Isotope\Model\Label::getTable()] = 'Isotope\\Model\\Label';
$GLOBALS['TL_MODELS'][\Isotope\Model\OrderStatus::getTable()] = 'Isotope\\Model\\OrderStatus';
$GLOBALS['TL_MODELS'][\Isotope\Model\Payment::getTable()] = 'Isotope\\Model\\Payment';
$GLOBALS['TL_MODELS'][\Isotope\Model\Product::getTable()] = 'Isotope\\Model\\Product';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCategory::getTable()] = 'Isotope\\Model\\ProductCategory';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollection::getTable()] = 'Isotope\\Model\\ProductCollection';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionDownload::getTable()] = 'Isotope\\Model\\ProductCollectionDownload';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionItem::getTable()] = 'Isotope\\Model\\ProductCollectionItem';
Example #19
0
 /**
  * Replace insert tag for an address
  *
  * @param Address     $address
  * @param string|null $attribute
  *
  * @return string
  */
 private function getValueForAddressTag(Address $address, $attribute = null)
 {
     if (null === $attribute) {
         return $address->generate();
     }
     $tokens = $address->getTokens();
     return $tokens[$attribute];
 }
Example #20
0
 /**
  * Get default address for this collection and address type
  * @return  AddressModel
  */
 protected function getDefaultAddress()
 {
     $objAddress = AddressModel::findOneBy(array('ptable=?', 'pid=?', 'isDefaultShipping=?'), array('tl_iso_product_collection', Isotope::getCart()->id, '1'));
     if (null === $objAddress) {
         $objShippingAddress = Isotope::getCart()->getShippingAddress();
         if (null === $objShippingAddress) {
             $objAddress = new AddressModel();
         } else {
             $objAddress = clone $objShippingAddress;
         }
         $objAddress->ptable = 'tl_iso_product_collection';
         $objAddress->pid = Isotope::getCart()->id;
         $objAddress->isDefaultShipping = '1';
         $objAddress->isDefaultBilling = '';
         if ($objAddress->country == '') {
             $objAddress->country = Isotope::getConfig()->shipping_country;
         }
     }
     return $objAddress;
 }
Example #21
0
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_enableLimit'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_enableLimit'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('submitOnChange' => true, 'tl_class' => 'clr w50 m12'), 'sql' => "char(1) NOT NULL default ''");
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_perPage'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_perPage'], 'exclude' => true, 'default' => '8,12,32,64', 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 64, 'rgxp' => 'extnd', 'tl_class' => 'w50'), 'sql' => "varchar(64) NOT NULL default ''");
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_cart_jumpTo'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_cart_jumpTo'], 'exclude' => true, 'inputType' => 'pageTree', 'foreignKey' => 'tl_page.title', 'eval' => array('fieldType' => 'radio', 'tl_class' => 'clr'), 'explanation' => 'jumpTo', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy'));
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_checkout_jumpTo'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_checkout_jumpTo'], 'exclude' => true, 'inputType' => 'pageTree', 'foreignKey' => 'tl_page.title', 'eval' => array('fieldType' => 'radio', 'tl_class' => 'clr'), 'explanation' => 'jumpTo', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy'));
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_listingSortField'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_listingSortField'], 'exclude' => true, 'inputType' => 'select', 'options_callback' => array('Isotope\\Backend\\Module\\Callback', 'getSortingFields'), 'eval' => array('includeBlankOption' => true, 'tl_class' => 'clr w50'), 'sql' => "varchar(255) NOT NULL default ''", 'save_callback' => array(array('Isotope\\Backend', 'truncateProductCache')));
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_listingSortDirection'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_listingSortDirection'], 'exclude' => true, 'default' => 'DESC', 'inputType' => 'select', 'options' => array('DESC', 'ASC'), 'reference' => &$GLOBALS['TL_LANG']['tl_module']['sortingDirection'], 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(8) NOT NULL default ''");
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_buttons'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_buttons'], 'exclude' => true, 'inputType' => 'checkboxWizard', 'default' => array('add_to_cart'), 'options_callback' => array('Isotope\\Backend\\Module\\Callback', 'getButtons'), 'eval' => array('multiple' => true, 'tl_class' => 'clr'), 'sql' => "blob NULL");
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_related_categories'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_related_categories'], 'exclude' => true, 'inputType' => 'checkboxWizard', 'foreignKey' => \Isotope\Model\RelatedCategory::getTable() . '.name', 'eval' => array('mandatory' => true, 'multiple' => true, 'tl_class' => 'clr'), 'sql' => "blob NULL", 'relation' => array('type' => 'hasMany', 'load' => 'lazy'));
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_includeMessages'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_includeMessages'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('doNotCopy' => true, 'tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''");
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_continueShopping'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_continueShopping'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''");
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_address'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_address'], 'exclude' => true, 'inputType' => 'checkbox', 'options' => array('billing', 'shipping'), 'reference' => &$GLOBALS['TL_LANG']['tl_module']['iso_address'], 'eval' => array('mandatory' => true, 'multiple' => true), 'sql' => "blob NULL");
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_addressFields'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_addressFields'], 'exclude' => true, 'inputType' => 'checkboxWizard', 'options_callback' => function () {
    \Controller::loadDataContainer(\Isotope\Model\Address::getTable());
    \System::loadLanguageFile(\Isotope\Model\Address::getTable());
    $arrOptions = array();
    $arrDCA =& $GLOBALS['TL_DCA'][\Isotope\Model\Address::getTable()]['fields'];
    foreach ($arrDCA as $k => $arrField) {
        if (!$arrField['eval']['feEditable']) {
            continue;
        }
        $arrOptions[$k] = $arrField['label'][0];
    }
    return $arrOptions;
}, 'eval' => array('mandatory' => true, 'multiple' => true, 'tl_class' => 'clr'), 'sql' => "blob NULL");
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_productcache'] = array('sql' => "blob NULL");
/**
 * Limit notification choices
 */
$GLOBALS['TL_DCA']['tl_module']['fields']['nc_notification']['eval']['ncNotificationChoices']['iso_checkout'] = array('iso_order_status_change');
$GLOBALS['TL_DCA']['tl_module']['fields']['nc_notification']['eval']['ncNotificationChoices']['iso_checkoutmember'] = array('iso_order_status_change');
$GLOBALS['TL_DCA']['tl_module']['fields']['nc_notification']['eval']['ncNotificationChoices']['iso_checkoutguest'] = array('iso_order_status_change');