Новости Joomla

0 Пользователей и 1 Гость просматривают эту тему.
  • 2 Ответов
  • 2592 Просмотров
*

PML-web developer

  • Новичок
  • 3
  • 0 / 0
Здравствуйте, форумчане!
У меня есть вопрос, возможно ли добавить в модальное окно кнопку "добавить товар и + - товары"?

У меня установлена Joomla 2.5 + VM 2.0.10. Вот сайт: http://eda2.realsvyaz.ru/index.php/%D0%B1%D0%B0%D0%BA%D0%B0%D0%BB%D0%B5%D1%8F/%D0%BC%D1%83%D0%BA%D0%B0/1%D0%BA%D0%B3-%D0%BC%D1%83%D0%BA%D0%B0-%D0%B2-%D1%81-%D0%BC%D0%B0%D0%BA%D1%84%D0%B02012-07-31-12-58-35_-detail

Я тут добавил форму кнопки и +- товары, что дальше делать не знаю. Т.к. при изменении файла: /components/com_virtuemart/controllers/cart.php Кнопка вообще перестает работать, в не модальном окне.

Вот код, что не так делаю или подскажите, что делать?
Возможно ли это сделать вообще?

Код
<?php

/**
 *
 * Controller for the cart
 *
 * @package VirtueMart
 * @subpackage Cart
 * @author RolandD
 * @author Max Milbers
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: cart.php 6001 2012-05-04 15:11:06Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

// Load the controller framework
jimport('joomla.application.component.controller');

/**
 * Controller for the cart view
 *
 * @package VirtueMart
 * @subpackage Cart
 * @author RolandD
 * @author Max Milbers
 */
class VirtueMartControllerCart extends JController {

/**
* Construct the cart
*
* @access public
* @author Max Milbers
*/
public function __construct() {
parent::__construct();
if (VmConfig::get('use_as_catalog', 0)) {
$app = JFactory::getApplication();
$app->redirect('index.php');
} else {
if (!class_exists('VirtueMartCart'))
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
if (!class_exists('calculationHelper'))
require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php');
}
$this->useSSL = VmConfig::get('useSSL', 0);
$this->useXHTML = true;
}


/**
* Add the product to the cart
*
* @author RolandD
* @author Max Milbers
* @access public
*/
public function add() {
$mainframe = JFactory::getApplication();
if (VmConfig::get('use_as_catalog', 0)) {
$msg = JText::_('COM_VIRTUEMART_PRODUCT_NOT_ADDED_SUCCESSFULLY');
$type = 'error';
$mainframe->redirect('index.php', $msg, $type);
}
$cart = VirtueMartCart::getCart();
if ($cart) {
$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
$success = true;
if ($cart->add($virtuemart_product_ids,$success)) {
$msg = JText::_('COM_VIRTUEMART_PRODUCT_ADDED_SUCCESSFULLY');
$type = '';
} else {
$msg = JText::_('COM_VIRTUEMART_PRODUCT_NOT_ADDED_SUCCESSFULLY');
$type = 'error';
}

$mainframe->enqueueMessage($msg, $type);
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'));

} else {
$mainframe->enqueueMessage('Cart does not exist?', 'error');
}
}

public function getHTML() {
$result = '';

$quantity = (isset($this->product->min_order_level) && (int) $this->product->min_order_level > 0)
? $this->product->min_order_level
: 1;

$result .= '<div style="float:left;"><img id="medium-image" class="medium-image" alt="6409_250px6" src="/images/stories/virtuemart/product/resized/6409_250px6_190x190.jpg"></div>
<div style="float:right;" class="addtocart-area">
<form method="post" class="product js-recalculate" action="index.php" >
<div class="addtocart-bar" id="myDiv">
<span class="quantity-box">
<input type="text" class="quantity-input js-recalculate" name="quantity[]" value="' . $quantity . '">
</span>
<span class="quantity-controls js-recalculate">
<input type="button" class="quantity-controls quantity-plus">
<input type="button" class="quantity-controls quantity-minus"/>
</span>
';
   // Add the button
   $button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO');
   $button_cls = 'addtocart-button'; //$button_cls = 'addtocart_button';
   $button_name = 'addtocart'; //$button_cls = 'addtocart_button';
   // Display the add to cart button
   $stockhandle = VmConfig::get('stockhandle', 'none');
   if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($this->product->product_in_stock - $this->product->product_ordered) < 1) {
$button_lbl = JText::_('COM_VIRTUEMART_CART_NOTIFY');
$button_cls = 'notify-button';
$button_name = 'notifycustomer';
   }
   //vmdebug('$stockhandle '.$stockhandle.' and stock '.$this->product->product_in_stock.' ordered '.$this->product->product_ordered);
   $result .= '
<span class="addtocart-button">
<input type="submit" name="' . $button_name . '"  class="' . $button_cls . '" value="' . $button_lbl . '" title="' . $button_lbl . '" />
   </span>

   <div class="clear"></div>
</div>
</form>
</div>';

return $result;
}


/**
* Add the product to the cart, with JS: PML
*
*/
public function addJS() {

//maybe we should use $mainframe->close(); or jexit();instead of die;
/* Load the cart helper */
//require_once(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
$this->json = null;
$cart = VirtueMartCart::getCart(false);
if ($cart) {
// Get a continue link */
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
if ($virtuemart_category_id) {
$categoryLink = '&view=category&virtuemart_category_id=' . $virtuemart_category_id;
} else
$categoryLink = '';
$continue_link = JRoute::_('index.php?option=com_virtuemart' . $categoryLink);
$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
$errorMsg = JText::_('COM_VIRTUEMART_CART_PRODUCT_ADDED');
if ($cart->add($virtuemart_product_ids, $errorMsg )) {

$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING'). '</a>';
$this->json->msg .= '<a class="showcart floatright" href="' . JRoute::_("index.php?option=com_virtuemart&view=cart"). '">' . JText::_('COM_VIRTUEMART_CART_SHOW_MODAL'). '</a>';

//pml1 - Тут я пробую вставить кнопку но ни чего не получается.
$this->json->msg .= $this->getHTML();
//pml end

if ($errorMsg) $this->json->msg .= '<div>'.$errorMsg.'</div>';
$this->json->stat = '1';
} else {
// $this->json->msg = '<p>' . $cart->getError(). '</p>';
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING'). '</a>';
$this->json->msg .= '<div>'.$errorMsg.'</div>';
$this->json->stat = '2';
}
} else {
$this->json->msg = '<a href="' . JRoute::_('index.php?option=com_virtuemart'). '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING'). '</a>';
$this->json->msg .= '<p>' . JText::_('COM_VIRTUEMART_MINICART_ERROR'). '</p>';
$this->json->stat = '0';
}
//$this->json->msg='<img src="http://eda2.realsvyaz.ru/images/stories/virtuemart/product/resized/6409_250px6_190x190.jpg">';
echo json_encode($this->json);
jExit();
}
//END PML
/**
* Add the product to the cart, with JS
*
* @author Max Milbers
* @access public
*/
public function viewJS() {

if (!class_exists('VirtueMartCart'))
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
$cart = VirtueMartCart::getCart(false);
$this->data = $cart->prepareAjaxData();
$lang = JFactory::getLanguage();
$extension = 'com_virtuemart';
$lang->load($extension); //  when AJAX it needs to be loaded manually here >> in case you are outside VirtueMart !
if ($this->data->totalProduct > 1)
$this->data->totalProductTxt = JText::sprintf('COM_VIRTUEMART_CART_X_PRODUCTS', $this->data->totalProduct);
else if ($this->data->totalProduct == 1)
$this->data->totalProductTxt = JText::_('COM_VIRTUEMART_CART_ONE_PRODUCT');
else
$this->data->totalProductTxt = JText::_('COM_VIRTUEMART_EMPTY_CART');
if ($this->data->dataValidated == true) {
$taskRoute = '&task=confirm';
$linkName = JText::_('COM_VIRTUEMART_CART_CONFIRM');
} else {
$taskRoute = '';
$linkName = JText::_('COM_VIRTUEMART_CART_SHOW');
}
$this->data->cart_show = '<a class="floatright" href="' . JRoute::_("index.php?option=com_virtuemart&view=cart" . $taskRoute, $this->useXHTML, $this->useSSL). '">' . $linkName . '</a>';
$this->data->billTotal = $lang->_('COM_VIRTUEMART_CART_TOTAL'). ' : <strong>' . $this->data->billTotal . '</strong>';
echo json_encode($this->data);
Jexit();
}

/**
* For selecting couponcode to use, opens a new layout
*
* @author Max Milbers
*/
public function edit_coupon() {

$view = $this->getView('cart', 'html');
$view->setLayout('edit_coupon');

// Display it all
$view->display();
}

/**
* Store the coupon code in the cart
* @author Oscar van Eijk
*/
public function setcoupon() {
$mainframe = JFactory::getApplication();
/* Get the coupon_code of the cart */
$coupon_code = JRequest::getVar('coupon_code', ''); //TODO VAR OR INT OR WORD?
if ($coupon_code) {

$cart = VirtueMartCart::getCart();
if ($cart) {
$msg = $cart->setCouponCode($coupon_code);
if (!empty($msg)) {
$mainframe->enqueueMessage($msg, 'error');
}
// $cart->setDataValidation(); //Not needed already done in the getCart function
if ($cart->getInCheckOut()) {
$mainframe = JFactory::getApplication();
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&task=checkout'));
}
}
}
parent::display();
// self::Cart();
}

/**
* For selecting shipment, opens a new layout
*
* @author Max Milbers
*/
public function edit_shipment() {


$view = $this->getView('cart', 'html');
$view->setLayout('select_shipment');

// Display it all
$view->display();
}

/**
* Sets a selected shipment to the cart
*
* @author Max Milbers
*/
public function setshipment() {

/* Get the shipment ID from the cart */
$virtuemart_shipmentmethod_id = JRequest::getInt('virtuemart_shipmentmethod_id', '0');
$cart = VirtueMartCart::getCart();
if ($cart) {
//Now set the shipment ID into the cart
if (!class_exists('vmPSPlugin')) require(JPATH_VM_PLUGINS . DS . 'vmpsplugin.php');
JPluginHelper::importPlugin('vmshipment');
$cart->setShipment($virtuemart_shipmentmethod_id);
//Add a hook here for other payment methods, checking the data of the choosed plugin
$_dispatcher = JDispatcher::getInstance();
$_retValues = $_dispatcher->trigger('plgVmOnSelectCheckShipment', array(   &$cart));
$dataValid = true;
foreach ($_retValues as $_retVal) {
if ($_retVal === true ) {
// Plugin completed succesfull; nothing else to do
$cart->setCartIntoSession();
break;
} else if ($_retVal === false ) {
$mainframe = JFactory::getApplication();
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&task=editshipment',$this->useXHTML,$this->useSSL), $_retVal);
break;
}
}

if ($cart->getInCheckOut()) {
$mainframe = JFactory::getApplication();
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&task=checkout') );
}
}
// self::Cart();
parent::display();
}

/**
* To select a payment method
*
* @author Max Milbers
*/
public function editpayment() {

$view = $this->getView('cart', 'html');
$view->setLayout('select_payment');

// Display it all
$view->display();
}

/**
* To set a payment method
*
* @author Max Milbers
* @author Oscar van Eijk
* @author Valerie Isaksen
*/
function setpayment() {

/* Get the payment id of the cart */
//Now set the payment rate into the cart
$cart = VirtueMartCart::getCart();
if ($cart) {
if(!class_exists('vmPSPlugin')) require(JPATH_VM_PLUGINS.DS.'vmpsplugin.php');
JPluginHelper::importPlugin('vmpayment');
//Some Paymentmethods needs extra Information like
$virtuemart_paymentmethod_id = JRequest::getInt('virtuemart_paymentmethod_id', '0');
$cart->setPaymentMethod($virtuemart_paymentmethod_id);

//Add a hook here for other payment methods, checking the data of the choosed plugin
$msg = '';
$_dispatcher = JDispatcher::getInstance();
$_retValues = $_dispatcher->trigger('plgVmOnSelectCheckPayment', array( $cart, &$msg));
$dataValid = true;
foreach ($_retValues as $_retVal) {
if ($_retVal === true ) {
// Plugin completed succesfull; nothing else to do
$cart->setCartIntoSession();
break;
} else if ($_retVal === false ) {
  $app = JFactory::getApplication();
  $app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&task=editpayment',$this->useXHTML,$this->useSSL), $msg);
  break;
}
}
// $cart->setDataValidation(); //Not needed already done in the getCart function
// vmdebug('setpayment $cart',$cart);
if ($cart->getInCheckOut()) {
$app = JFactory::getApplication();
$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&task=checkout'), $msg);
}
}
// self::Cart();
parent::display();
}

/**
* Delete a product from the cart
*
* @author RolandD
* @access public
*/
public function delete() {
$mainframe = JFactory::getApplication();
/* Load the cart helper */
$cart = VirtueMartCart::getCart();
if ($cart->removeProductCart())
$mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_PRODUCT_REMOVED_SUCCESSFULLY'));
else
$mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_PRODUCT_NOT_REMOVED_SUCCESSFULLY'), 'error');

$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'));
}

/**
* Delete a product from the cart
*
* @author RolandD
* @access public
*/
public function update() {
$mainframe = JFactory::getApplication();
/* Load the cart helper */
$cartModel = VirtueMartCart::getCart();
if ($cartModel->updateProductCart())
$mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_PRODUCT_UPDATED_SUCCESSFULLY'));
else
$mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_PRODUCT_NOT_UPDATED_SUCCESSFULLY'), 'error');

$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'));
}

/**
* Checks for the data that is needed to process the order
*
* @author Max Milbers
*
*
*/
public function checkout() {
//Tests step for step for the necessary data, redirects to it, when something is lacking

$cart = VirtueMartCart::getCart();
if ($cart && !VmConfig::get('use_as_catalog', 0)) {
$cart->checkout();
}
}

/**
* Executes the confirmDone task,
* cart object checks itself, if the data is valid
*
* @author Max Milbers
*
*
*/
public function confirm() {

//Use false to prevent valid boolean to get deleted
$cart = VirtueMartCart::getCart();
if ($cart) {
$cart->confirmDone();
$view = $this->getView('cart', 'html');
$view->setLayout('order_done');
// Display it all
$view->display();
} else {
$mainframe = JFactory::getApplication();
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'), JText::_('COM_VIRTUEMART_CART_DATA_NOT_VALID'));
}
}

function cancel() {
$mainframe = JFactory::getApplication();
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'), 'Cancelled');
}

}

//pure php no Tag
« Последнее редактирование: 22.10.2012, 15:43:43 от PML-web developer »
*

ELLE

  • Глобальный модератор
  • 4505
  • 893 / 0
*

PML-web developer

  • Новичок
  • 3
  • 0 / 0
Есть кто еще может помочь?
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Яндекс карты. Добавить &amp;quot;чтобы переместить карту проведите по ней двумя пальцами&amp;quot;

Автор safronoff343

Ответов: 1
Просмотров: 26449
Последний ответ 14.05.2025, 07:18:54
от Lemonez
YT Shortcode - не отображается кнопка в редакторах

Автор Missile

Ответов: 0
Просмотров: 1855
Последний ответ 13.10.2022, 17:36:57
от Missile
Как добавить аддоны shortcode ultimate в sp page builder?

Автор chen

Ответов: 0
Просмотров: 3284
Последний ответ 23.07.2022, 10:16:40
от chen
SP Page Builder Возможно ли добавить кнопку в текстовое поле?

Автор AlexP750

Ответов: 7
Просмотров: 6717
Последний ответ 15.08.2021, 14:19:53
от AlexP750
Как добавить изображение ссылкой VirtueMart 3?

Автор VBedya

Ответов: 0
Просмотров: 1703
Последний ответ 27.04.2021, 13:02:05
от VBedya