示例#1
0
文件: plugin.php 项目: A-Bush/pprod
 /**
  * Only returns plugins that have a specific event
  *
  * @param $eventName
  * @param $folder
  * @return array of JTable objects
  */
 public static function getPluginsWithEvent($eventName, $folder = 'K2Store')
 {
     $return = array();
     if ($plugins = K2StoreHelperPlugin::getPlugins($folder)) {
         foreach ($plugins as $plugin) {
             if (K2StoreHelperPlugin::hasEvent($plugin, $eventName)) {
                 $return[] = $plugin;
             }
         }
     }
     return $return;
 }
示例#2
0
文件: checkout.php 项目: A-Bush/pprod
 function shipping_payment_method()
 {
     $app = JFactory::getApplication();
     $view = $this->getView('checkout', 'html');
     $task = JRequest::getVar('task');
     $model = $this->getModel('checkout');
     $cart_helper = new K2StoreHelperCart();
     $cart_model = $this->getModel('mycart');
     if (!$cart_helper->hasProducts()) {
         $msg = JText::_('K2STORE_NO_ITEMS_IN_CART');
         $link = JRoute::_('index.php?option=com_k2store&view=mycart');
         $app->redirect($link, $msg);
     }
     //prepare order
     $order = $this->_order;
     $order = $this->populateOrder(false);
     // get the order totals
     $order->calculateTotals();
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('k2store');
     //custom fields
     $selectableBase = new K2StoreSelectableBase();
     $view->assign('fieldsClass', $selectableBase);
     $address_table = JTable::getInstance('address', 'Table');
     $fields = $selectableBase->getFields('payment', $address, 'address');
     $view->assign('fields', $fields);
     $view->assign('address', $address_table);
     //get layout settings
     $view->assign('storeProfile', K2StoreHelperCart::getStoreAddress());
     $showShipping = false;
     if ($this->params->get('show_shipping_address', 0)) {
         $showShipping = true;
     }
     if ($isShippingEnabled = $cart_model->getShippingIsEnabled()) {
         $showShipping = true;
         //$this->setShippingMethod();
     }
     $view->assign('showShipping', $showShipping);
     if ($showShipping) {
         $rates = $this->getShippingRates();
         $shipping_layout = "shipping_yes";
         //	if (!$this->session->has('shipping_address_id', 'k2store'))
         //	{
         //		$shipping_layout = "shipping_calculate";
         //	}
         $shipping_method_form = $this->getShippingHtml($shipping_layout);
         $view->assign('showShipping', $showShipping);
         $view->assign('shipping_method_form', $shipping_method_form);
         $view->assign('rates', $rates);
     }
     //process payment plugins
     $showPayment = true;
     if ((double) $order->order_total == (double) '0.00') {
         $showPayment = false;
     }
     $view->assign('showPayment', $showPayment);
     require_once JPATH_SITE . '/components/com_k2store/helpers/plugin.php';
     $payment_plugins = K2StoreHelperPlugin::getPluginsWithEvent('onK2StoreGetPaymentPlugins');
     $plugins = array();
     if ($payment_plugins) {
         foreach ($payment_plugins as $plugin) {
             $results = $dispatcher->trigger("onK2StoreGetPaymentOptions", array($plugin->element, $order));
             if (in_array(true, $results, true)) {
                 $plugins[] = $plugin;
             }
         }
     }
     if (count($plugins) == 1) {
         $plugins[0]->checked = true;
         //	ob_start();
         $html = $this->getPaymentForm($plugins[0]->element, true);
         //	$html = json_decode( ob_get_contents() );
         //	ob_end_clean();
         $view->assign('payment_form_div', $html);
     }
     $view->assign('plugins', $plugins);
     //also set the payment methods to session
     //terms and conditions
     if ($this->params->get('termsid')) {
         $tos_link = JRoute::_('index.php?option=com_k2&view=item&tmpl=component&id=' . $this->params->get('termsid'));
     } else {
         $tos_link = null;
     }
     $view->assign('tos_link', $tos_link);
     //Get and Set Model
     $view->setModel($model, true);
     $view->assign('order', $order);
     $view->assign('params', $this->params);
     $view->setLayout('checkout_shipping_payment');
     ob_start();
     $view->display();
     $html = ob_get_contents();
     ob_end_clean();
     echo $html;
     $app->close();
 }