Exemple #1
0
 public function upgrade()
 {
     $pkg = Package::getByHandle('vivid_store');
     if (version_compare($pkg->getPackageVersion(), '2.1', '<')) {
         Installer::renameDatabaseTables($pkg);
         Installer::refreshDatabase($pkg);
         /** Version 1.1 ***********************************************/
         /**************************************************************/
         /*
          * 1. Installs new payment method: Invoice
          *
          */
         $invoicePM = PaymentMethod::getByHandle('invoice');
         if (!is_object($invoicePM)) {
             PaymentMethod::add('invoice', 'Invoice', $pkg);
         }
         /** Version 2.0 ***********************************************/
         /**************************************************************/
         /*
          * 1. Installs new PageType: store_product
          * 2. Installs a parent page to publish products under
          * 3. Install Product block
          * 4. Set pagetype defaults
          * 5. Give default for measurement units
          * 6. Install a fileset for digital downloads
          * 7. Install product attributes
          *
          */
         /*
          * 1. Installs new PageType: store_product
          */
         $this->installStoreProductPageType($pkg);
         /*
          * 2. Installs a parent page to publish products under
          */
         //first check and make sure the config isn't set.
         $publishTarget = Config::get('vividstore.productPublishTarget');
         if ($publishTarget < 1 || empty($publishTarget)) {
             //if not, install the proudct detail page if needed.
             $productParentPage = Page::getByPath('/product-detail');
             if ($productParentPage->isError()) {
                 $home = Page::getByID(HOME_CID);
                 $pageType = PageType::getByHandle('page');
                 $pageTemplate = PageTemplate::getByHandle('full');
                 $productParentPage = $home->add($pageType, array('cName' => t('Product Detail'), 'cHandle' => 'product-detail', 'pkgID' => $pkg->pkgID), $pageTemplate);
                 Page::getByPath('/product-detail')->setAttribute('exclude_nav', 1);
             }
             //set the config to publish under the new page.
             Config::save('vividstore.productPublishTarget', $productParentPage->getCollectionID());
         }
         /*
          * 3. Install Product Block
          */
         $productBlock = BlockType::getByHandle("vivid_product");
         if (!is_object($productBlock)) {
             BlockType::installBlockTypeFromPackage('vivid_product', $pkg);
         }
         /*
          * 3. Install Product PageType Defaults
          */
         $pageType = PageType::getByHandle('store_product');
         $template = $pageType->getPageTypeDefaultPageTemplateObject();
         $pageObj = $pageType->getPageTypePageTemplateDefaultPageObject($template);
         $bt = BlockType::getByHandle('vivid_product');
         $blocks = $pageObj->getBlocks('Main');
         if ($blocks[0] && $blocks[0]->getBlockTypeHandle() == "content") {
             $blocks[0]->deleteBlock();
         }
         if (count($blocks) < 1) {
             $data = array('productLocation' => 'page', 'showProductName' => 1, 'showProductDescription' => 1, 'showProductDetails' => 1, 'showProductPrice' => 1, 'showImage' => 1, 'showCartButton' => 1, 'showGroups' => 1);
             $pageObj->addBlock($bt, 'Main', $data);
         }
         /*
          * 5. Measurement Units.
          */
         $sizeUnits = Config::get('vividstore.sizeUnit');
         if (empty($sizeUnits)) {
             Config::save('vividstore.sizeUnit', 'in');
         }
         $weightUnits = Config::get('vividstore.weightUnit');
         if (empty($weightUnits)) {
             Config::save('vividstore.weightUnit', 'lb');
         }
         /*
          * 6. Fileset for digital downloads
          */
         $fs = FileSet::getByName('Digital Downloads');
         if (!is_object($fs)) {
             FileSet::add("Digital Downloads");
         }
         /*
          * 7. Product Attributes page
          */
         $attrPage = Page::getByPath('/dashboard/store/products/attributes');
         if (!is_object($attrPage) || $attrPage->isError()) {
             SinglePage::add('/dashboard/store/products/attributes', $pkg);
         }
         /*
          *  Add email order attribute
          */
         $text = AttributeType::getByHandle('text');
         $oakc = AttributeKeyCategory::getByHandle('store_order');
         $orderCustSet = AttributeSet::getByHandle('order_customer');
         $email = StoreOrderKey::getByHandle('email');
         if (!is_object($email)) {
             StoreOrderKey::add($text, array('akHandle' => 'email', 'akName' => t('Email')), $pkg)->setAttributeSet($orderCustSet);
         }
         // convert legacy config items to current config storage
         // applies for version 2.1.1 and below
         $db = Database::get();
         $configitems = $db->GetAll("SELECT * FROM Config WHERE configGroup='vividstore'");
         if (!empty($configitems)) {
             foreach ($configitems as $config) {
                 Config::save('vividstore.' . $config['configItem'], $config['configValue']);
             }
             $db->Execute("DELETE FROM Config WHERE configGroup='vividstore'");
         }
     }
     Installer::addOrderStatusesToDatabase($pkg);
     $paypalPM = PaymentMethod::getByHandle('paypal_standard');
     if (!is_object($paypalPM)) {
         PaymentMethod::add('paypal_standard', 'PayPal Standard', $pkg);
     }
     $co = Config::get('vividstore.cartOverlay');
     if (empty($co)) {
         Config::save('vividstore.cartOverlay', false);
     }
     parent::upgrade();
 }
Exemple #2
0
 public static function installOrderAttribute($handle, $type, $pkg, $set, $data = null)
 {
     $attr = StoreOrderKey::getByHandle($handle);
     if (!is_object($attr)) {
         $name = Core::make("helper/text")->camelcase($handle);
         if (!$data) {
             $data = array('akHandle' => $handle, 'akName' => t($name));
         }
         StoreOrderKey::add($type, $data, $pkg)->setAttributeSet($set);
     }
 }
Exemple #3
0
        </div>
        <div class="col-sm-6">
            <?php 
    if ($order->getAttribute("shipping_address")->address1) {
        ?>
            <h4><?php 
        echo t("Shipping Information");
        ?>
</h4>
            <p>
                <?php 
        echo $order->getAttribute("shipping_first_name") . " " . $order->getAttribute("shipping_last_name");
        ?>
<br>
                <?php 
        echo $order->getAttributeValueObject(StoreOrderKey::getByHandle('shipping_address'))->getValue('displaySanitized', 'display');
        ?>
            </p>
            <?php 
    }
    ?>
        </div>
    </div>
    <h3><?php 
    echo t("Order Items");
    ?>
</h3>
    <hr>
    <table class="table table-striped">
        <thead>
            <tr>
Exemple #4
0
 public function getAttribute($ak, $displayMode = false)
 {
     if (!is_object($ak)) {
         $ak = StoreOrderKey::getByHandle($ak);
     }
     if (is_object($ak)) {
         $av = $this->getAttributeValueObject($ak);
         if (is_object($av)) {
             return $av->getValue($displayMode);
         }
     }
 }
Exemple #5
0
        ?>
            <div class="col-sm-6">
                <?php 
        if ($order->getAttribute("shipping_address")->address1) {
            ?>
                    <h4><?php 
            echo t("Shipping Information");
            ?>
</h4>
                    <p>
                        <?php 
            echo $order->getAttribute("shipping_first_name") . " " . $order->getAttribute("shipping_last_name");
            ?>
<br>
                        <?php 
            $shippingaddres = $order->getAttributeValueObject(StoreOrderKey::getByHandle('shipping_address'));
            if ($shippingaddres) {
                echo $shippingaddres->getValue('displaySanitized', 'display');
            }
            ?>
                    </p>
                <?php 
        }
        ?>
            </div>
        <?php 
    }
    ?>
    </div>
    <h3><?php 
    echo t("Order Info");