예제 #1
0
파일: checkout.php 프로젝트: A-Bush/pprod
 function validateSelectShipping($values)
 {
     $error = 0;
     if (isset($values['shippingrequired'])) {
         if ($values['shippingrequired'] == 1 && empty($values['shipping_plugin'])) {
             throw new Exception(JText::_('K2STORE_CHECKOUT_SELECT_A_SHIPPING_METHOD'));
             return false;
         }
     }
     //if order value is zero, then return true
     $order = $this->_order;
     // get the items and add them to the order
     $items = K2StoreHelperCart::getProducts();
     foreach ($items as $item) {
         $order->addItem($item);
     }
     $order->calculateTotals();
     if ((double) $order->order_total == (double) '0.00') {
         return true;
     }
     //trigger the plugin's validation function
     // no matter what, fire this validation plugin event for plugins that extend the checkout workflow
     $results = array();
     $dispatcher = JDispatcher::getInstance();
     $results = $dispatcher->trigger("onValidateSelectShipping", array($values));
     for ($i = 0; $i < count($results); $i++) {
         $result = $results[$i];
         if (!empty($result->error)) {
             throw new Exception($result->message);
             return false;
         }
     }
     if ($error == '1') {
         return false;
     }
     return true;
 }