本文整理汇总了PHP中TiendaHelperBase::generateMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP TiendaHelperBase::generateMessage方法的具体用法?PHP TiendaHelperBase::generateMessage怎么用?PHP TiendaHelperBase::generateMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiendaHelperBase
的用法示例。
在下文中一共展示了TiendaHelperBase::generateMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatePaymentOptions
function updatePaymentOptions()
{
$response = array();
$response['msg'] = '';
$response['error'] = '';
$error_message = '';
Tienda::load('TiendaHelperBase', 'helpers._base');
$helper = TiendaHelperBase::getInstance();
// get elements from post
$elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', JRequest::getVar('elements', '', 'post', 'string')));
// Test if elements are empty
// Return proper message to user
if (empty($elements)) {
// do form validation
// if it fails check, return message
$response['error'] = '1';
$response['msg'] = $helper->generateMessage(JText::_('COM_TIENDA_ERROR_WHILE_VALIDATING_THE_PARAMETERS'));
echo json_encode($response);
return;
}
// convert elements to array that can be binded
Tienda::load('TiendaHelperBase', 'helpers._base');
$helper = new TiendaHelperBase();
$submitted_values = $helper->elementsToArray($elements);
// Use AJAX to show plugins that are available
JLoader::import('com_tienda.library.json', JPATH_ADMINISTRATOR . '/components');
$this->setAddresses($submitted_values, false, true);
if (!$this->validateAddress($submitted_values, $this->billing_input_prefix, @$submitted_values['billing_address_id'], true)) {
$error_message = $helper->generateMessage(JText::_('COM_TIENDA_BILLING_ADDRESS_ERROR') . " :: " . $this->getError());
$response['error'] = '1';
$response['msg'] = $error_message;
echo json_encode($response);
return;
}
$model = $this->getModel('Checkout', 'TiendaModel');
$view = $this->getView('checkout', 'html');
$view->set('_controller', 'checkout');
$view->set('_view', 'checkout');
$view->set('_doTask', true);
$view->set('hidemenu', true);
$view->setModel($model, true);
$view->setLayout('payment_options');
$payment_plugins = $this->getPaymentOptions($this->_order);
$view->assign('payment_plugins', $payment_plugins);
$guest = false;
if ($this->defines->get('guest_checkout_enabled')) {
if (!$this->onepage_checkout) {
$guest = $this->user->id ? 0 : 1;
} else {
$guest = JRequest::getVar('guest', '0');
}
$guest = $guest ? true : false;
}
$this->populateOrder($guest);
$this->addCouponCodes($submitted_values);
$this->_order->calculateTotals();
if (count($payment_plugins) == 1) {
$payment_plugins[0]->checked = true;
$dispatcher = JDispatcher::getInstance();
$results = $dispatcher->trigger("onGetPaymentForm", array($payment_plugins[0]->element, ''));
$text = '';
for ($i = 0; $i < count($results); $i++) {
$text .= $results[$i];
}
$view->assign('payment_form_div', $text);
} else {
if (isset($submitted_values['_checked']['payment_plugin'])) {
foreach ($payment_plugins as $plugin) {
if ($plugin->element == $submitted_values['_checked']['payment_plugin']) {
$plugin->checked = true;
}
}
}
}
$showPayment = true;
if ((double) $this->_order->order_total == (double) '0.00') {
$showPayment = false;
}
$view->assign('showPayment', $showPayment);
ob_start();
$view->display();
$html = ob_get_contents();
ob_end_clean();
// set response array
$response = array();
$response['msg'] = $error_message . $html;
// encode and echo (need to echo to send back to browser)
echo json_encode($response);
return;
}
示例2: validate
/**
* Verifies the fields in a submitted form. Uses the table's check() method.
* Will often be overridden. Is expected to be called via Ajax
*
* @return unknown_type
*/
function validate()
{
Tienda::load('TiendaHelperBase', 'helpers._base');
$helper = new TiendaHelperBase();
$response = array();
$response['msg'] = '';
$response['error'] = '';
// get elements from post
$elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', JRequest::getVar('elements', '', 'post', 'string')));
// validate it using table's ->check() method
if (empty($elements)) {
// if it fails check, return message
$response['error'] = '1';
$response['msg'] = $helper->generateMessage(JText::_('COM_TIENDA_COULD_NOT_PROCESS_FORM'));
echo json_encode($response);
return;
}
if (!Tienda::getInstance()->get('shop_enabled', '1')) {
$response['msg'] = $helper->generateMessage("Shop Disabled");
$response['error'] = '1';
echo json_encode($response);
return false;
}
// convert elements to array that can be binded
$values = TiendaHelperBase::elementsToArray($elements);
$product_id = !empty($values['product_id']) ? (int) $values['product_id'] : JRequest::getInt('product_id');
$product_qty = !empty($values['product_qty']) ? (int) $values['product_qty'] : '1';
$attributes = array();
foreach ($values as $key => $value) {
if (substr($key, 0, 10) == 'attribute_') {
$attributes[] = $value;
}
}
sort($attributes);
$attributes_csv = implode(',', $attributes);
// Integrity checks on quantity being added
if ($product_qty < 0) {
$product_qty = '1';
}
// using a helper file to determine the product's information related to inventory
$availableQuantity = Tienda::getClass('TiendaHelperProduct', 'helpers.product')->getAvailableQuantity($product_id, $attributes_csv);
if ($availableQuantity->product_check_inventory && $product_qty > $availableQuantity->quantity) {
$response['msg'] = $helper->generateMessage(JText::sprintf("COM_TIENDA_NOT_AVAILABLE_QUANTITY", $availableQuantity->product_name, $product_qty));
$response['error'] = '1';
echo json_encode($response);
return false;
}
$product = JTable::getInstance('Products', 'TiendaTable');
$product->load(array('product_id' => $product_id));
// if product notforsale, fail
if ($product->product_notforsale) {
$response['msg'] = $helper->generateMessage("Product Not For Sale");
$response['error'] = '1';
echo json_encode($response);
return false;
}
$user = JFactory::getUser();
$keynames = array();
$keynames['user_id'] = $user->id;
if (empty($user->id)) {
$session = JFactory::getSession();
$keynames['session_id'] = $session->getId();
}
$keynames['product_id'] = $product_id;
$cartitem = JTable::getInstance('Carts', 'TiendaTable');
$cartitem->load($keynames);
if ($product->quantity_restriction) {
if ($product->quantity_restriction) {
$error = false;
$min = $product->quantity_min;
$max = $product->quantity_max;
if ($max) {
$remaining = $max - $cartitem->product_qty;
if ($product_qty > $remaining) {
$error = true;
$msg = $helper->generateMessage("You have reached the maximum quantity for this item. You can order another " . $remaining);
}
}
if ($min) {
if ($product_qty < $min) {
$error = true;
$msg = $helper->generateMessage("You have not reached the miminum quantity for this item. You have to order at least " . $min);
}
}
}
if ($error) {
$response['msg'] = $msg;
$response['error'] = '1';
echo json_encode($response);
return false;
}
}
// create cart object out of item properties
$item = new JObject();
//.........这里部分代码省略.........
示例3: TiendaHelperBase
function validateStep3($values)
{
Tienda::load('TiendaHelperBase', 'helpers._base');
$helper = new TiendaHelperBase();
$response = array();
$response['msg'] = '';
$response['error'] = '';
$msg = array();
$config = Tienda::getInstance();
//check if we have billing address id
if (empty($values['billing_input_address_id'])) {
$responseBilling = $this->validateAddress($values);
if (count($responseBilling)) {
$msg = array_merge($msg, $responseBilling);
$response['error'] = '1';
}
}
$session = JFactory::getSession();
$subtask = $session->get('subtask', 'shipping', 'tienda_pos');
switch ($subtask) {
case 'shipping':
//check if we have billing address id
if (empty($values['shipping_input_address_id'])) {
if (empty($values['sameasbilling'])) {
$responseShipping = $this->validateAddress($values, 'shipping');
if (count($responseShipping)) {
$msg = array_merge($msg, $responseShipping);
$response['error'] = '1';
}
}
} else {
if (empty($values['shipping_name'])) {
$response['error'] = '1';
$msg[] = JText::_('COM_TIENDA_PLEASE_SELECT_SHIPPING_METHOD');
}
}
break;
case 'payment':
default:
if (!empty($values['billing_input_address_id'])) {
if (empty($values['payment_plugin'])) {
$response['error'] = '1';
$msg[] = JText::_('COM_TIENDA_PLEASE_SELECT_PAYMENT_METHOD');
}
}
break;
}
$response['msg'] = $helper->generateMessage("<li>" . implode("</li><li>", $msg) . "</li>", false);
return $response;
}