コード例 #1
0
 /**
  *
  * @return unknown_type
  */
 function onAfterInitialise()
 {
     $success = null;
     if (!$this->isInstalled()) {
         return $success;
     }
     if (!$this->canRun()) {
         return $success;
     }
     Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
     $helper = new TiendaHelperSubscription();
     $helper->checkExpired();
     $helper->checkExpiring();
     return $success;
 }
コード例 #2
0
ファイル: usersubnum.php プロジェクト: annggeel/tienda
 /**
  * Tienda User store user method
  *
  * Method is called after user data is stored in the database
  * The sort order of this plugin must be set to be after the User - Tienda plugin, because
  * that creates an entry in userinfo, and we can't act without that.
  *
  * @param   array    holds the new user data
  * @param   boolean     true if a new user is stored
  * @param   boolean     true if user was succesfully stored in the database
  * @param   string      message
  */
 function onAfterStoreUser($user, $isnew, $success, $msg)
 {
     $create_address = $this->params->get('create_address', 0);
     if ($isnew) {
         // load the config class
         Tienda::load('Tienda', 'defines');
         $notify = $this->params->get('notify_person', 1);
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
         Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
         $component = JRequest::getCmd('option');
         $tokens = explode(' ', $user['name']);
         $last_name = $first_name = '';
         if (count($tokens) > 1) {
             $last_name = $tokens[count($tokens) - 1];
             $first_name = str_replace($last_name, '', $user['name']);
         } else {
             $last_name = $user['name'];
         }
         //save the subscription number
         $tblUser = JTable::getInstance('UserInfo', 'TiendaTable');
         $tblUser->load(array('user_id' => $user['id']));
         $tblUser->user_id = $user['id'];
         $tblUser->sub_number = TiendaHelperSubscription::getNextSubNum();
         // one-page checkout + other registrations that are not done via tienda -> we need to add data manually
         if ($component != 'com_tienda' || $component == 'com_tienda' && Tienda::getInstance()->get('one_page_checkout', 0)) {
             $tblUser->last_name = $last_name;
             $tblUser->first_name = $first_name;
             $tblUser->email = $user['email'];
         }
         if (!$tblUser->save()) {
             $this->sendNotification(JText::_('Error during saving subscription number'), $user['id']);
             JError::raiseError(500, JText::_('Error during saving subscription number'));
             return;
         }
         // we want to create a default address and are not registering via tienda
         // (tienda takes care about it automatically)
         if ($create_address && $component != 'com_tienda') {
             $tblAddress = JTable::getInstance('Addresses', 'TiendaTable');
             $tblAddress->user_id = $user['id'];
             $tblAddress->addresstype_id = 1;
             $tblAddress->address_name = $this->params->get('address_title', JText::_('Main Address Default'));
             $tblAddress->country_id = $this->params->get('default_country', 0);
             $tblAddress->zone_id = $this->params->get('default_zone', 0);
             $tblAddress->is_default_billing = 1;
             $tblAddress->is_default_shipping = 1;
             $tblAddress->last_name = $last_name;
             $tblAddress->first_name = $first_name;
             if (!$tblAddress->store()) {
                 $this->sendNotification(JText::_('Error during creating an empty address'), $user['id']);
                 JError::raiseError(500, JText::_('Error during creating an empty address'));
                 return;
             }
         }
     }
 }
コード例 #3
0
ファイル: subscriptions.php プロジェクト: annggeel/tienda
 public function getItem($pk = null, $refresh = false, $emptyState = true)
 {
     Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
     if ($item = parent::getItem($pk, $refresh, $emptyState)) {
         $item->link = 'index.php?option=com_tienda&view=subscriptions&task=edit&id=' . $item->subscription_id;
         $item->link_view = 'index.php?option=com_tienda&view=subscriptions&task=view&id=' . $item->subscription_id;
         $item->history = TiendaHelperSubscription::getHistory($item->subscription_id);
         Tienda::load('TiendaQuery', 'library.query');
         $q = new TiendaQuery();
         $q->select('order_hash');
         $q->from('#__tienda_orders');
         $q->where('order_id = ' . $item->order_id);
         $db = JFactory::getDbo();
         $db->setQuery($q);
         $item->order_hash = $db->loadResult();
     }
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onPrepare' . $this->getTable()->get('_suffix'), array(&$item));
     return $item;
 }
コード例 #4
0
ファイル: orders.php プロジェクト: annggeel/tienda
 /**
  * Adds an item to the order object
  * $item can be a named array with a minimum of 'product_id' and 'orderitem_quantity' and 'orderitem_attributes' (as CSV of productattributeoptions_ids)
  * $item can be an object with minimum of 'product_id' and 'orderitem_quantity' and 'orderitem_attributes' properties
  * $item can be a 'product_id' string
  * 
  * $this->_items['product_id'] = TableOrderItems() object;
  * 
  * @param object    $item   TableOrderItem object
  * @return void
  */
 function addItem($item)
 {
     Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
     $orderItem = JTable::getInstance('OrderItems', 'TiendaTable');
     if (is_array($item)) {
         $orderItem->bind($item);
     } elseif (is_object($item) && is_a($item, 'TiendaTableOrderItems')) {
         $orderItem = $item;
     } elseif (is_object($item)) {
         $orderItem->product_id = @$item->product_id;
         $orderItem->orderitem_quantity = @$item->orderitem_quantity;
         $orderItem->vendor_id = @$item->vendor_id;
         $orderItem->orderitem_attributes = @$item->orderitem_attributes;
     } else {
         $orderItem->product_id = $item;
         $orderItem->orderitem_quantity = '1';
         $orderItem->vendor_id = '0';
         $orderItem->orderitem_attributes = '';
     }
     // check whether/not the item recurs
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $model = JModel::getInstance('Products', 'TiendaModel');
     $model->setId($orderItem->product_id);
     $product = $model->getItem();
     $orderItem->subscription_prorated = $product->subscription_prorated;
     // flag the order as recurring
     if ($product->product_recurs) {
         $this->order_recurs = true;
     }
     if ($orderItem->subscription_prorated) {
         // set the orderitem's recurring product values
         $orderItem->orderitem_recurs = $product->product_recurs;
         $orderItem->recurring_price = $product->recurring_price;
         $orderItem->recurring_payments = $product->recurring_payments;
         $orderItem->recurring_period_interval = $product->recurring_period_interval;
         $orderItem->recurring_period_unit = $product->recurring_period_unit;
         $orderItem->recurring_trial_price = $product->recurring_trial_price;
         if ($product->subscription_prorated) {
             $result = TiendaHelperSubscription::calculateProRatedTrial($product->subscription_prorated_date, $product->subscription_prorated_term, $product->recurring_period_unit, $product->recurring_trial_price, $product->subscription_prorated_charge);
             $orderItem->recurring_trial = $result['trial'];
             $orderItem->recurring_trial_period_interval = $result['interval'];
             $orderItem->recurring_trial_period_unit = $result['unit'];
             $orderItem->recurring_trial_price = $result['price'];
         } else {
             $orderItem->recurring_trial = $product->recurring_trial;
             $orderItem->recurring_trial_period_interval = $product->recurring_trial_period_interval;
             $orderItem->recurring_trial_period_unit = $product->recurring_trial_period_unit;
         }
     }
     if (!empty($product->product_subscription)) {
         // set the orderitem's subscription product values
         $orderItem->orderitem_subscription = $product->product_subscription;
         $orderItem->subscription_lifetime = $product->subscription_lifetime;
         $orderItem->subscription_period_interval = $product->subscription_period_interval;
         $orderItem->subscription_period_unit = $product->subscription_period_unit;
     }
     // Use hash to separate items when customer is buying the same product from multiple vendors
     // and with different attribs
     $hash = intval($orderItem->product_id) . "." . intval($orderItem->vendor_id) . "." . $orderItem->orderitem_attributes;
     $dispatcher = JDispatcher::getInstance();
     $results = $dispatcher->trigger("onGetAdditionalOrderitemKeyValues", array($orderItem));
     //              JFactory::getApplication()->enqueueMessage( 'orders.php - line 236 - '.Tienda::dump( $results ) );
     foreach ($results as $result) {
         foreach ($result as $key => $value) {
             $hash = $hash . "." . $value;
         }
     }
     if (isset($orderItem->cart_id)) {
         unset($orderItem->cart_id);
     }
     //              $orderItem->orderitem_id = null; // so it can create a new ordreitem, if needed
     if (!empty($this->_items[$hash])) {
         // merely update quantity if item already in list
         $this->_items[$hash]->orderitem_quantity += $orderItem->orderitem_quantity;
     } else {
         $this->_items[$hash] = $orderItem;
     }
     // add the vendor to the order
     $this->addVendor($orderItem);
     // add productdownloads records to the order
     // not necessary yet
     // $this->addDownloads( $orderItem );
 }
コード例 #5
0
ファイル: products.php プロジェクト: annggeel/tienda
 /**
  * Set basic properties for the item, whether in a list or a singleton
  *
  * @param unknown_type $item
  * @param unknown_type $key
  * @param unknown_type $refresh
  */
 protected function prepareItem(&$item, $key = 0, $refresh = false)
 {
     Tienda::load("TiendaHelperProduct", 'helpers.product');
     Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
     $helper_product = new TiendaHelperProduct();
     if (!empty($item->product_recurs)) {
         $item->recurring_price = $item->price;
         if ($item->subscription_prorated) {
             Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
             $result = TiendaHelperSubscription::calculateProRatedTrial($item->subscription_prorated_date, $item->subscription_prorated_term, $item->recurring_period_unit, $item->recurring_trial_price, $item->subscription_prorated_charge);
             $item->price = $result['price'];
             $item->prorated_price = $result['price'];
             $item->prorated_interval = $result['interval'];
             $item->prorated_unit = $result['unit'];
             // $item->recurring_trial = $result['trial'];
         } else {
             if (!empty($item->recurring_trial)) {
                 $item->price = $item->recurring_trial_price;
             }
         }
     }
     $user_id = $this->getState('user.id', 0);
     $qty = $this->getState('product.qty', -1);
     if ($qty > -1) {
         $user_group = TiendaHelperUser::getUserGroup($user_id, $item->product_id);
         $price = TiendaHelperProduct::getPrice($item->product_id, $qty, $user_group);
         $item->price = $price->product_price;
     }
     $item->product_parameters = new DSCParameter($item->product_params);
     $item->slug = $item->product_alias ? ":{$item->product_alias}" : "";
     $item->link = 'index.php?option=com_tienda&view=products&task=view&id=' . $item->product_id;
     $item->link_edit = 'index.php?option=com_tienda&view=products&task=edit&id=' . $item->product_id;
     $item->product_categories = $this->getCategories($item->product_id);
     $item->default_attributes = $helper_product->getDefaultAttributes($item->product_id);
     $item->product_classes = null;
     foreach ($item->product_categories as $cat) {
         $item->product_classes .= " " . $cat->category_alias;
     }
     if (!empty($item->product_class_suffix)) {
         $item->product_classes .= " " . $item->product_class_suffix;
     }
     $item->product_classes = trim($item->product_classes);
     parent::prepareItem($item, $key, $refresh);
 }
コード例 #6
0
ファイル: manufacturers.php プロジェクト: annggeel/tienda
 /**
  * Gets a product's files list
  * formatted for display
  *
  * @param int $address_id
  * @return string html
  */
 function getFiles($product_id)
 {
     $html = '';
     // get the product's files
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $model = JModel::getInstance('ProductFiles', 'TiendaModel');
     $model->setState('filter_product', $product_id);
     $model->setState('filter_enabled', 1);
     //$model->setState( 'filter_purchaserequired', 1 );
     $items = $model->getList();
     // get the user's active subscriptions to this product, if possible
     $submodel = JModel::getInstance('Subscriptions', 'TiendaModel');
     $submodel->setState('filter_userid', JFactory::getUser()->id);
     $submodel->setState('filter_productid', $product_id);
     $subs = $submodel->getList();
     if (!empty($items)) {
         // reconcile the list of files to the date the sub's files were last checked
         Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
         $subhelper = new TiendaHelperSubscription();
         $subhelper->reconcileFiles($subs);
         Tienda::load('TiendaHelperBase', 'helpers._base');
         $helper = TiendaHelperBase::getInstance('ProductDownload', 'TiendaHelper');
         $filtered_items = $helper->filterRestricted($items, JFactory::getUser()->id);
         $view = $this->getView('products', 'html');
         $view->set('_controller', 'products');
         $view->set('_view', 'products');
         $view->set('_doTask', true);
         $view->set('hidemenu', true);
         $view->setModel($model, true);
         $view->setLayout('product_files');
         $view->set('downloadItems', $filtered_items[0]);
         $view->set('nondownloadItems', $filtered_items[1]);
         $view->set('product_id', $product_id);
         ob_start();
         $view->display();
         $html = ob_get_contents();
         ob_end_clean();
     }
     return $html;
 }
コード例 #7
0
ファイル: default.php プロジェクト: annggeel/tienda
    echo $item->order_id;
    ?>
                    </a>
                </td>
				<td style="text-align: left;">
            <?php 
    if ($display_subnum && strlen($item->sub_number)) {
        ?>
            	<?php 
        Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
        ?>
            	<b><?php 
        echo JText::_('COM_TIENDA_SUB_NUM');
        ?>
:</b> <?php 
        echo TiendaHelperSubscription::displaySubNum($item->sub_number);
        ?>
<br />
            <?php 
    }
    ?>
				    <?php 
    if (!empty($item->user_name)) {
        ?>
    					<?php 
        echo $item->user_name . ' [ ' . $item->user_id . ' ]';
        ?>
    					<br/>
    					&nbsp;&nbsp;&bull;&nbsp;&nbsp;<?php 
        echo $item->email . ' [ ' . $item->user_username . ' ]';
        ?>
コード例 #8
0
?>
:</td>
                <td><?php 
if (empty($row->product_id)) {
    // doing a new product, so display a note
    ?>
                    <div class="note well">
                        <?php 
    echo JText::_('COM_TIENDA_CLICK_APPLY_TO_BE_ABLE_TO_ADD_ISSUES_TO_THE_PRODUCT');
    ?>
                    </div> <?php 
} else {
    Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
    $next_issue = TiendaHelperSubscription::getMarginalIssue($row->product_id);
    $last_issue = TiendaHelperSubscription::getMarginalIssue($row->product_id, 'DESC');
    $num_issues = TiendaHelperSubscription::getNumberIssues($row->product_id);
    ?>
 [<?php 
    echo TiendaUrl::popup("index.php?option=com_tienda&view=products&task=setissues&id=" . $row->product_id . "&tmpl=component", JText::_('COM_TIENDA_SET_ISSUES'));
    ?>
]<br /> <?php 
    if (isset($next_issue)) {
        echo '<b>' . JText::_('COM_TIENDA_NEXT_ISSUE_PUBLISHED') . ':</b> ' . JHTML::_('date', $next_issue->publishing_date, JText::_('DATE_FORMAT_LC4')) . '<br />';
    }
    if (isset($last_issue)) {
        echo '<b>' . JText::_('COM_TIENDA_LAST_ISSUE_PUBLISHED') . ':</b> ' . JHTML::_('date', $last_issue->publishing_date, JText::_('DATE_FORMAT_LC4')) . '<br />';
    }
    echo '<b>' . JText::_('COM_TIENDA_ISSUES_LEFT') . ':</b> ' . @$num_issues;
    ?>
<br /> <?php 
}
コード例 #9
0
ファイル: products.php プロジェクト: annggeel/tienda
 /**
  * Gets a product's files list
  * formatted for display
  *
  * @param int $address_id
  * @return string html
  */
 function getFiles($view, $product_id)
 {
     $html = '';
     // get the product's files
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $model = JModel::getInstance('ProductFiles', 'TiendaModel');
     $model->setState('filter_product', $product_id);
     $model->setState('filter_enabled', 1);
     //$model->setState( 'filter_purchaserequired', 1 );
     $items = $model->getList();
     // get the user's active subscriptions to this product, if possible
     $submodel = JModel::getInstance('Subscriptions', 'TiendaModel');
     $submodel->setState('filter_userid', JFactory::getUser()->id);
     $submodel->setState('filter_productid', $product_id);
     $subs = $submodel->getList();
     if (!empty($items)) {
         // reconcile the list of files to the date the sub's files were last checked
         Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
         $subhelper = new TiendaHelperSubscription();
         $subhelper->reconcileFiles($subs);
         Tienda::load('TiendaHelperBase', 'helpers._base');
         $helper = TiendaHelperBase::getInstance('ProductDownload', 'TiendaHelper');
         $filtered_items = $helper->filterRestricted($items, JFactory::getUser()->id);
         $view->setModel($model, true);
         $product_file_data = new stdClass();
         $product_file_data->downloadItems = $filtered_items[0];
         $product_file_data->nondownloadItems = $filtered_items[1];
         $product_file_data->product_id = $product_id;
         $lyt = $view->getLayout();
         $view->setLayout('product_files');
         $view->product_file_data = $product_file_data;
         ob_start();
         echo $view->loadTemplate(null);
         $html = ob_get_contents();
         ob_end_clean();
         $view->setLayout($lyt);
         unset($view->product_file_data);
     }
     return $html;
 }
コード例 #10
0
ファイル: wishlistitems.php プロジェクト: annggeel/tienda
 public function getList($refresh = false, $getEav = true, $options = array())
 {
     static $pa, $pao;
     if (empty($pa)) {
         $pa = array();
     }
     if (empty($pao)) {
         $pao = array();
     }
     Tienda::load("TiendaHelperUser", 'helpers.user');
     Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
     $user_helper = TiendaHelperBase::getInstance('User');
     $product_helper = TiendaHelperBase::getInstance('Product');
     if (empty($this->_list) || $refresh) {
         DSCTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
         $items = parent::getList($refresh);
         // If no item in the list, return an array()
         if (empty($items)) {
             return array();
         }
         foreach ($items as $item) {
             if (empty($item->product_qty)) {
                 $item->product_qty = '1';
             }
             $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()->toMySQL());
             //checking if we do price override
             $item->product_price_override->override = true;
             if (!empty($item->product_price_override)) {
                 $item->product_price = $item->product_price_override->product_price;
             }
             if ($item->product_recurs) {
                 $item->recurring_price = $item->product_price;
                 if ($item->subscription_prorated) {
                     $result = TiendaHelperSubscription::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';
             $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] = DSCTable::getInstance('ProductAttributeOptions', 'TiendaTable');
                         $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;
                     } 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;
                     }
                     $item->orderitem_attributes_price = number_format($item->orderitem_attributes_price, '5', '.', '');
                     $item->product_sku .= $table->productattributeoption_code;
                     // store a csv of the attrib names, built by Attribute name + Attribute option name
                     if (empty($pa[$table->productattribute_id])) {
                         $pa[$table->productattribute_id] = DSCTable::getInstance('ProductAttributes', 'TiendaTable');
                         $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);
                     }
                 }
                 // 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->_list = $items;
     }
     return $this->_list;
 }
コード例 #11
0
ファイル: default.php プロジェクト: annggeel/tienda
            </tr>
            <?php 
if (Tienda::getInstance()->get('display_subnum', 0)) {
    ?>
            <tr>
                <th style="width: 100px;">
                    <?php 
    echo JText::_('COM_TIENDA_SUB_NUM');
    ?>
                </th>
                <td colspan="2">
		            	<?php 
    Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
    ?>
    	        		<?php 
    echo TiendaHelperSubscription::displaySubNum($userinfo->sub_number);
    ?>
                    
                </td>
            </tr>
            <?php 
}
?>
            <tr>
                <th style="width: 100px;">
                    <?php 
echo JText::_('COM_TIENDA_PRIMARY_SHIPPING_ADDRESS');
?>
                </th>
                <td>
                    <?php