Esempio n. 1
0
 /**
  * Return downloads associated with this product collection item
  *
  * @return ProductCollectionDownload[]
  */
 public function getDownloads()
 {
     if (null === $this->arrDownloads) {
         $this->arrDownloads = array();
         $objDownloads = ProductCollectionDownload::findBy('pid', $this->id);
         if (null !== $objDownloads) {
             while ($objDownloads->next()) {
                 $this->arrDownloads[] = $objDownloads->current();
             }
         }
     }
     return $this->arrDownloads;
 }
Esempio n. 2
0
 */
$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';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionSurcharge::getTable()] = 'Isotope\\Model\\ProductCollectionSurcharge';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductPrice::getTable()] = 'Isotope\\Model\\ProductPrice';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCache::getTable()] = 'Isotope\\Model\\ProductCache';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductType::getTable()] = 'Isotope\\Model\\ProductType';
$GLOBALS['TL_MODELS'][\Isotope\Model\RelatedCategory::getTable()] = 'Isotope\\Model\\RelatedCategory';
$GLOBALS['TL_MODELS'][\Isotope\Model\RelatedProduct::getTable()] = 'Isotope\\Model\\RelatedProduct';
$GLOBALS['TL_MODELS'][\Isotope\Model\RequestCache::getTable()] = 'Isotope\\Model\\RequestCache';
$GLOBALS['TL_MODELS'][\Isotope\Model\Shipping::getTable()] = 'Isotope\\Model\\Shipping';
$GLOBALS['TL_MODELS'][\Isotope\Model\TaxClass::getTable()] = 'Isotope\\Model\\TaxClass';
$GLOBALS['TL_MODELS'][\Isotope\Model\TaxRate::getTable()] = 'Isotope\\Model\\TaxRate';
/**
 * Checkout steps
 */
$GLOBALS['ISO_CHECKOUTSTEP'] = array('address' => array('\\Isotope\\CheckoutStep\\BillingAddress', '\\Isotope\\CheckoutStep\\ShippingAddress'), 'shipping' => array('\\Isotope\\CheckoutStep\\ShippingMethod'), 'payment' => array('\\Isotope\\CheckoutStep\\PaymentMethod'), 'review' => array('\\Isotope\\CheckoutStep\\OrderConditionsOnTop', '\\Isotope\\CheckoutStep\\OrderInfo', '\\Isotope\\CheckoutStep\\OrderConditionsBeforeProducts', '\\Isotope\\CheckoutStep\\OrderProducts', '\\Isotope\\CheckoutStep\\OrderConditionsAfterProducts'));
Esempio n. 3
0
 /**
  * Lock collection from begin modified
  */
 public function lock()
 {
     $this->ensureNotLocked();
     global $objPage;
     $time = time();
     $this->pageId = (int) $objPage->id;
     $this->language = (string) $GLOBALS['TL_LANGUAGE'];
     $this->createPrivateAddresses();
     $this->updateDatabase();
     // Add surcharges to the collection
     $sorting = 128;
     foreach ($this->getSurcharges() as $objSurcharge) {
         $objSurcharge->pid = $this->id;
         $objSurcharge->tstamp = $time;
         $objSurcharge->sorting = $sorting;
         $objSurcharge->save();
         $sorting += 128;
     }
     // Add downloads from products to the collection
     foreach (ProductCollectionDownload::createForProductsInCollection($this) as $objDownload) {
         $objDownload->save();
     }
     // Can't use model, it would not save as soon as it's locked
     \Database::getInstance()->query("UPDATE " . static::$strTable . " SET locked=" . $time . " WHERE id=" . $this->id);
     $this->arrData['locked'] = $time;
     // !HOOK: pre-process checkout
     if (isset($GLOBALS['ISO_HOOKS']['collectionLocked']) && is_array($GLOBALS['ISO_HOOKS']['collectionLocked'])) {
         foreach ($GLOBALS['ISO_HOOKS']['collectionLocked'] as $callback) {
             \System::importStatic($callback[0])->{$callback[1]}($this);
         }
     }
     $this->clearCache();
 }
Esempio n. 4
0
 /**
  * Prevent delete on a download which has been sold
  * @param   array
  * @param   string
  * @param   string
  * @param   string
  * @param   string
  * @param   array
  * @return  string
  * @see     https://contao.org/de/manual/3.1/data-container-arrays.html#button_callback
  */
 public function deleteButton($row, $href, $label, $title, $icon, $attributes)
 {
     if (ProductCollectionDownload::countBy('download_id', $row['id']) > 0) {
         return \Image::getHtml(preg_replace('/\\.gif$/i', '_.gif', $icon)) . ' ';
     }
     return '<a href="' . $this->addToUrl($href . '&amp;id=' . $row['id']) . '" title="' . specialchars($title) . '"' . $attributes . '>' . \Image::getHtml($icon, $label) . '</a> ';
 }
Esempio n. 5
0
 /**
  * Process the order checkout
  * @return boolean
  */
 public function checkout()
 {
     if ($this->checkout_complete) {
         return true;
     }
     // !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]($this) === false) {
                 \System::log('Callback ' . $callback[0] . '::' . $callback[1] . '() cancelled checkout for Order ID ' . $this->id, __METHOD__, TL_ERROR);
                 return false;
             }
         }
     }
     $this->createPrivateAddresses();
     // Finish and lock the order (do this now, because otherwise surcharges etc. will not be loaded form the database)
     $this->checkout_complete = true;
     $this->generateDocumentNumber($this->getRelated('config_id')->orderPrefix, (int) $this->getRelated('config_id')->orderDigits);
     $this->lock();
     \System::log('New order ID ' . $this->id . ' has been placed', __METHOD__, TL_ACCESS);
     // Add downloads from products to the collection
     /** @var ProductCollectionDownload[] $arrDownloads */
     $arrDownloads = ProductCollectionDownload::createForProductsInCollection($this);
     foreach ($arrDownloads as $objDownload) {
         $objDownload->save();
     }
     // Delete cart after migrating to order
     if (($objCart = Cart::findByPk($this->source_collection_id)) !== null) {
         $objCart->delete();
     }
     // Delete all other orders that relate to the current cart
     if (($objOrders = static::findSiblingsBy('source_collection_id', $this)) !== null) {
         /** @var Order $objOrder */
         foreach ($objOrders as $objOrder) {
             if (!$objOrder->isLocked()) {
                 $objOrder->delete();
             }
         }
     }
     // Generate tokens
     $arrTokens = $this->getNotificationTokens($this->nc_notification);
     // Send notification
     if ($this->nc_notification) {
         $blnNotificationError = true;
         if (($objNotification = Notification::findByPk($this->nc_notification)) !== null) {
             $arrResult = $objNotification->send($arrTokens, $this->language);
             if (!empty($arrResult) && !in_array(false, $arrResult)) {
                 $blnNotificationError = false;
             }
         }
         if ($blnNotificationError === true) {
             \System::log('Error sending new order notification for order ID ' . $this->id, __METHOD__, TL_ERROR);
         }
     } else {
         \System::log('No notification for order ID ' . $this->id, __METHOD__, TL_ERROR);
     }
     // Set order status only if a payment module has not already set it
     if ($this->order_status == 0) {
         $this->updateOrderStatus($this->getRelated('config_id')->orderstatus_new);
     }
     // !HOOK: post-process checkout
     if (isset($GLOBALS['ISO_HOOKS']['postCheckout']) && is_array($GLOBALS['ISO_HOOKS']['postCheckout'])) {
         foreach ($GLOBALS['ISO_HOOKS']['postCheckout'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $objCallback->{$callback}[1]($this, $arrTokens);
         }
     }
     return true;
 }