VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: varikov1 on November 19, 2018, 09:44:21 AM

Title: Virtuemart stt_cart
Post by: varikov1 on November 19, 2018, 09:44:21 AM
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

Title: Re: Virtuemart stt_cart
Post by: Studio 42 on November 19, 2018, 14:47:55 PM
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.