Ejemplo n.º 1
0
        ?>
	<?php 
        if (is_object($field)) {
            ?>
		<dt><?php 
            echo JText::_($field->label);
            ?>
:</dt>
		<dd>
		<?php 
            if (is_array($field->value)) {
                echo '<br />';
                foreach ($field->value as $value) {
                    echo '- ' . JText::_($value) . '<br/>';
                }
            } elseif (K2StoreOrdersHelper::isJson(stripslashes($field->value))) {
                $json_values = json_decode(stripslashes($field->value));
                if (is_array($json_values)) {
                    foreach ($json_values as $value) {
                        echo '- ' . JText::_($value) . '<br/>';
                    }
                } else {
                    echo JText::_($field->value);
                }
            } else {
                echo JText::_($field->value);
            }
            ?>
		</dd>
<?php 
        }
Ejemplo n.º 2
0
 /**
  * This method occurs after payment is attempted,
  * and fires the onPostPayment plugin event
  *
  * @return unknown_type
  */
 function confirmPayment()
 {
     $app = JFactory::getApplication();
     $orderpayment_type = $app->input->getString('orderpayment_type');
     // Get post values
     $values = $app->input->getArray($_POST);
     //backward compatibility for payment plugins
     foreach ($values as $name => $value) {
         $app->input->set($name, $value);
     }
     //set the guest mail to null if it is present
     //check if it was a guest checkout
     $account = $this->session->get('account', 'register', 'k2store');
     // get the order_id from the session set by the prePayment
     $orderpayment_id = (int) $app->getUserState('k2store.orderpayment_id');
     if ($account != 'guest') {
         $order_link = 'index.php?option=com_k2store&view=orders&task=view&id=' . $orderpayment_id;
     } else {
         $guest_token = $app->getUserState('k2store.order_token');
         $order_link = 'index.php?option=com_k2store&view=orders&task=view';
         //assign to another session variable, for security reasons
         if ($this->session->has('guest', 'k2store')) {
             $guest = $this->session->get('guest', array(), 'k2store');
             $this->session->set('guest_order_email', $guest['billing']['email']);
             $this->session->set('guest_order_token', $guest_token);
         }
     }
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('k2store');
     $html = "";
     $order = $this->_order;
     $order->load(array('id' => $orderpayment_id));
     // free product? set the state to confirmed and save the order.
     if (!empty($orderpayment_id) && (double) $order->order_total == (double) '0.00') {
         $order->order_state = trim(JText::_('CONFIRMED'));
         $order->order_state_id = '1';
         // PAYMENT RECEIVED.
         if ($order->save()) {
             // remove items from cart
             K2StoreHelperCart::removeOrderItems($order->id);
         }
         //send email
         require_once JPATH_SITE . '/components/com_k2store/helpers/orders.php';
         K2StoreOrdersHelper::sendUserEmail($order->user_id, $order->order_id, $order->transaction_status, $order->order_state, $order->order_state_id);
     } else {
         // get the payment results from the payment plugin
         $results = $dispatcher->trigger("onK2StorePostPayment", array($orderpayment_type, $values));
         // Display whatever comes back from Payment Plugin for the onPrePayment
         for ($i = 0; $i < count($results); $i++) {
             $html .= $results[$i];
         }
         // re-load the order in case the payment plugin updated it
         $order->load(array('id' => $orderpayment_id));
     }
     // $order_id would be empty on posts back from Paypal, for example
     if (isset($orderpayment_id)) {
         //unset a few things from the session.
         $this->session->clear('shipping_method', 'k2store');
         $this->session->clear('shipping_methods', 'k2store');
         $this->session->clear('shipping_values', 'k2store');
         $this->session->clear('payment_method', 'k2store');
         $this->session->clear('payment_methods', 'k2store');
         $this->session->clear('payment_values', 'k2store');
         $this->session->clear('guest', 'k2store');
         $this->session->clear('customer_note', 'k2store');
         //save the coupon to the order_coupons table for tracking and unset session.
         if ($this->session->has('coupon', 'k2store')) {
             $coupon_info = K2StoreHelperCart::getCoupon($this->session->get('coupon', '', 'k2store'));
             if ($coupon_info) {
                 $order_coupons = JTable::getInstance('OrderCoupons', 'Table');
                 $order_coupons->set('coupon_id', $coupon_info->coupon_id);
                 $order_coupons->set('orderpayment_id', $orderpayment_id);
                 $order_coupons->set('customer_id', JFactory::getUser()->id);
                 $order_coupons->set('amount', $order->order_discount);
                 $order_coupons->set('created_date', JFactory::getDate()->toSql());
                 $order_coupons->store();
             }
         }
         //clear the session
         $this->session->clear('coupon', 'k2store');
         //trigger onAfterOrder plugin event
         $results = $dispatcher->trigger("onK2StoreAfterPayment", array($order));
         foreach ($results as $result) {
             $html .= $result;
         }
         // Set display
         $view = $this->getView('checkout', 'html');
         $view->setLayout('postpayment');
         $view->set('_doTask', true);
         $params = $params = JComponentHelper::getParams('com_k2store');
         if ($params->get('show_postpayment_orderlink', 1)) {
             $view->assign('order_link', JRoute::_($order_link));
         }
         $view->assign('plugin_html', $html);
         // Get and Set Model
         $model = $this->getModel('checkout');
         $view->setModel($model, true);
         $view->display();
     }
     return;
 }
Ejemplo n.º 3
0
 /**
  * Processes the payment form
  * and returns HTML to be displayed to the user
  * generally with a success/failed message
  *
  * @param $data     array       form post data
  * @return string   HTML to display
  */
 function _postPayment($data)
 {
     // Process the payment
     $app = JFactory::getApplication();
     $vars = new JObject();
     $html = '';
     $orderpayment_id = $app->input->getInt('orderpayment_id');
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2store/tables');
     $orderpayment = JTable::getInstance('Orders', 'Table');
     $orderpayment->load($orderpayment_id);
     if ($orderpayment->id == $orderpayment_id) {
         $payment_status = $this->getPaymentStatus($this->params->get('payment_status', 4));
         $orderpayment->transaction_status = $payment_status;
         $orderpayment->order_state = $payment_status;
         $orderpayment->order_state_id = $this->params->get('payment_status', 4);
         // DEFAULT: PENDING
         // save the orderpayment
         if ($orderpayment->save()) {
             JLoader::register('K2StoreHelperCart', JPATH_SITE . '/components/com_k2store/helpers/cart.php');
             // remove items from cart
             K2StoreHelperCart::removeOrderItems($orderpayment->id);
         } else {
             $errors[] = $orderpayment->getError();
         }
         // let us inform the user that the order is successful
         require_once JPATH_SITE . '/components/com_k2store/helpers/orders.php';
         K2StoreOrdersHelper::sendUserEmail($orderpayment->user_id, $orderpayment->order_id, $orderpayment->transaction_status, $orderpayment->order_state, $orderpayment->order_state_id);
         $vars->onafterpayment_text = $this->params->get('onafterpayment', '');
         // display the layout
         $html = $this->_getLayout('postpayment', $vars);
         // append the article with cash payment information
         $html .= $this->_displayArticle();
     }
     return $html;
 }
Ejemplo n.º 4
0
 function orderstatesave()
 {
     $app = JFactory::getApplication();
     $id = $app->input->getInt('id', 0);
     $order_state_id = $app->input->getInt('order_state_id', 0);
     $notify_customer = $app->input->getInt('notify_customer', 0);
     // $status_values = array(1 => JText::_('K2STORE_Confirmed'), 3 => JText::_('K2STORE_Failed'), 4 => JText::_('K2STORE_Pending'));
     if (isset($order_state_id) && $order_state_id > 0) {
         require_once JPATH_ADMINISTRATOR . '/components/com_k2store/models/orderstatuses.php';
         $os_model = new K2StoreModelOrderstatuses();
         $order_state = $os_model->getOrderStateByID($order_state_id)->orderstatus_name;
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2store/tables');
         $order = JTable::getInstance('Orders', 'Table');
         $order->load($id);
         if ($order->id == $id) {
             //lets change the status
             $order->order_state = $order_state;
             $order->order_state_id = $order_state_id;
             if ($order->store()) {
                 $msg = JText::_('K2STORE_ORDER_STATUS_UPDATE_SUCCESSFUL');
                 if (isset($notify_customer) && $notify_customer == 1) {
                     require_once JPATH_SITE . '/components/com_k2store/helpers/orders.php';
                     K2StoreOrdersHelper::sendUserEmail($order->user_id, $order->order_id, $order->transaction_status, $order->order_state, $order->order_state_id);
                 } else {
                     require_once JPATH_ADMINISTRATOR . '/components/com_k2store/library/inventory.php';
                     K2StoreInventory::setInventory($order->id, $order_state_id);
                 }
             } else {
                 $msg = JText::_('K2STORE_ORDER_STATUS_UPDATE_FAILED');
             }
         } else {
             $msg = JText::_('K2STORE_ORDER_STATUS_UPDATE_FAILED');
         }
     } else {
         $msg = JText::_('K2STORE_CHOOSE_AN_ORDER_STATUS');
     }
     $link = 'index.php?option=com_k2store&view=orders&task=view&id=' . $order->id;
     $this->setRedirect($link, $msg);
 }
Ejemplo n.º 5
0
    ?>
				<td><a
					href="<?php 
    echo JRoute::_(K2StoreItem::getK2Link($item->product_id));
    ?>
">
						<?php 
    echo JText::_($item->orderitem_name);
    ?>
 </a> <br />

					 	<!-- start of orderitem attributes -->

						<!-- backward compatibility -->
						<?php 
    if (!K2StoreOrdersHelper::isJSON(stripslashes($item->orderitem_attribute_names))) {
        ?>

							<?php 
        if (!empty($item->orderitem_attribute_names)) {
            ?>
								<span><?php 
            echo $item->orderitem_attribute_names;
            ?>
</span>
							<?php 
        }
        ?>
						<br />
						<?php 
    } else {
Ejemplo n.º 6
0
 /**
  * Processes the payment form
  * and returns HTML to be displayed to the user
  * generally with a success/failed message
  *
  * @param $data     array       form post data
  * @return string   HTML to display
  */
 function _postPayment($data)
 {
     // Process the payment
     $app = JFactory::getApplication();
     $vars = new JObject();
     $html = '';
     $orderpayment_id = $app->input->getInt('orderpayment_id');
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2store/tables');
     $orderpayment = JTable::getInstance('Orders', 'Table');
     $orderpayment->load($orderpayment_id);
     if ($orderpayment->id == $orderpayment_id) {
         $bank_information = $this->params->get('bank_information', '');
         //we have to save the bank information in the customer note because that is the only field availale to display now
         //TODO: Trigger a plugin event so that you can show custom info depending on the payment plugin.
         //get the customer note. We dont want to overwrite it.
         if (JString::strlen($bank_information) > 5) {
             $customer_note = $orderpayment->customer_note;
             $html = '<br />';
             $html .= '<strong>' . JText::_('K2STORE_BANK_TRANSFER_INSTRUCTIONS') . '</strong>';
             $html .= '<br />';
             $html .= $bank_information;
             $orderpayment->customer_note = $customer_note . $html;
         }
         $payment_status = $this->getPaymentStatus($this->params->get('payment_status', 4));
         $orderpayment->transaction_status = $payment_status;
         $orderpayment->order_state = $payment_status;
         $orderpayment->order_state_id = $this->params->get('payment_status', 4);
         // DEFAULT: PENDING
         // save the orderpayment
         if ($orderpayment->save()) {
             JLoader::register('K2StoreHelperCart', JPATH_SITE . '/components/com_k2store/helpers/cart.php');
             // remove items from cart
             K2StoreHelperCart::removeOrderItems($orderpayment->id);
         } else {
             $errors[] = $orderpayment->getError();
         }
         // let us inform the user that the order is successful
         require_once JPATH_SITE . '/components/com_k2store/helpers/orders.php';
         K2StoreOrdersHelper::sendUserEmail($orderpayment->user_id, $orderpayment->order_id, $orderpayment->transaction_status, $orderpayment->order_state, $orderpayment->order_state_id);
         $vars->onafterpayment_text = $this->params->get('onafterpayment', '');
         // display the layout
         $html = $this->_getLayout('postpayment', $vars);
         // append the article with banktransfer payment information
         $html .= $this->_displayArticle();
     }
     return $html;
 }
Ejemplo n.º 7
0
 /**
  * Processes the payment form
  * and returns HTML to be displayed to the user
  * generally with a success/failed message
  *
  * @param $data     array       form post data
  * @return string   HTML to display
  */
 function _postPayment($data)
 {
     // Process the payment
     $vars = new JObject();
     $orderpayment_id = JRequest::getVar('orderpayment_id');
     $offline_payment_method = JRequest::getVar('offline_payment_method');
     $formatted = array('offline_payment_method' => $offline_payment_method);
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2store' . DS . 'tables');
     $orderpayment = JTable::getInstance('Orders', 'Table');
     //remove this after live.
     //$orderpayment_id = substr($orderpayment_id, 2, 3);
     $orderpayment->load($orderpayment_id);
     $orderpayment->transaction_details = implode("\n", $formatted);
     //$orderpayment->transaction_status = JText::_('Pending_Payment');
     //$orderpayment->order_state = JText::_('Pending');
     $payment_status = $this->getPaymentStatus($this->params->get('payment_status', 4));
     $orderpayment->transaction_status = $payment_status;
     $orderpayment->order_state = $payment_status;
     $orderpayment->order_state_id = $this->params->get('payment_status', 4);
     // PENDING
     // save the orderpayment
     if ($orderpayment->save()) {
         JLoader::register('K2StoreHelperCart', JPATH_SITE . '/components/com_k2store/helpers/cart.php');
         // remove items from cart
         K2StoreHelperCart::removeOrderItems($orderpayment->id);
     } else {
         $errors[] = $orderpayment->getError();
     }
     // let us inform the user that the order is successful
     require_once JPATH_SITE . '/components/com_k2store/helpers/orders.php';
     K2StoreOrdersHelper::sendUserEmail($orderpayment->user_id, $orderpayment->order_id, $orderpayment->transaction_status, $orderpayment->order_state, $orderpayment->order_state_id);
     $vars->onafterpayment_text = $this->params->get('onafterpayment', '');
     // display the layout
     $html = $this->_getLayout('postpayment', $vars);
     // append the article with offline payment information
     $html .= $this->_displayArticle();
     return $html;
 }
Ejemplo n.º 8
0
 function getCustomField($row, $type = 'billing', $fieldname, $valuetype)
 {
     if ($type == 'billing') {
         $field = 'all_billing';
     } elseif ($type == 'shipping') {
         $field = 'all_shipping';
     } elseif ($type == 'payment') {
         $field = 'all_payment';
     }
     $result = '';
     $label = '';
     $fields = array();
     if (!empty($row->{$field}) && JString::strlen($row->{$field}) > 0) {
         $custom_fields = json_decode(stripslashes($row->{$field}));
         if (isset($custom_fields) && count($custom_fields)) {
             foreach ($custom_fields as $namekey => $field) {
                 if (!property_exists($row, $type . '_' . $namekey) && !property_exists($row, 'user_' . $namekey) && $namekey != 'country_id' && $namekey != 'zone_id' && $namekey != 'option' && $namekey != 'task' && $namekey != 'view') {
                     $fields[$namekey] = $field;
                 }
             }
         }
     }
     if (isset($fields) && count($fields)) {
         if (array_key_exists($fieldname, $fields)) {
             $field = $fields[$fieldname];
             if (is_object($field)) {
                 $label = JText::_($field->label);
                 if (is_array($field->value)) {
                     foreach ($field->value as $value) {
                         $result .= '- ' . JText::_($value) . '<br/>';
                     }
                 } elseif (K2StoreOrdersHelper::isJson(stripslashes($field->value))) {
                     $json_values = json_decode(stripslashes($field->value));
                     foreach ($json_values as $value) {
                         $result .= '- ' . JText::_($value) . '<br/>';
                     }
                 } else {
                     $result .= JText::_($field->value);
                 }
             }
         }
     }
     if ($valuetype == 'label') {
         return $label;
     }
     return $result;
 }