News:

Support the VirtueMart project and become a member

Main Menu

Virtuemart stt_cart

Started by varikov1, November 19, 2018, 09:44:21 AM

Previous topic - Next topic

varikov1

Please help. Was bought a plugin for AutoSave the recycle bin. Now there is a need to record in session also the prices of goods. Why we removed price from the session , name of the product and remaining everything is fine - continue.

This plugin

defined('_JEXEC') or die('Restricted access');



jimport('joomla.plugin.plugin');



class plgSystemstt_cartusave extends JPlugin {



    function __construct($event, $params) {

parent::__construct($event, $params);

    }



    function onAfterRoute() {

$session = null;

if (JFactory::getApplication()->isAdmin()) {

return;

}

$user = JFactory::getUser();

$userid = $user->get('id');



if ($userid && JRequest::getCmd('option') == 'com_virtuemart' && JRequest::getCmd('view') == 'cart' ) {

$this->putCart();

}

if ($userid && JRequest::getCmd('option') == 'com_sttvmorder' && JRequest::getCmd('view') == 'cart' ) {

$this->putCart();

}

    }



function putCart()

{

$user = JFactory::getUser();

$userid = $user->get('id');

if(!$userid) return;



$db = JFactory::getDBO();

$db->setQuery('DELETE FROM #__sttcartusave WHERE userid=' . $db->Quote($userid));

$db->query();



$session = JFactory::getSession($options);

$cartSession = $session->get('vmcart', 0, 'vm');

if (!empty($cartSession)) {

$db->setQuery("INSERT INTO #__sttcartusave (created,vmcart,userid) values(NOW()," .

$db->Quote($cartSession) .

', ' . $db->Quote($userid) . ')');

$db->query();

}

}

}



?>


This virtuemart code attachments


Studio 42

The prices in cart are $cart->cartPrices.
You have to set it and save it in the table if you need to use it after. else you have to load in cart session the saved cart to set the new prices.