Author Topic: Virtuemart stt_cart  (Read 202 times)

varikov1

  • Beginner
  • *
  • Posts: 1
  • A beginner
Virtuemart stt_cart
« 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
Code: [Select]
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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3514
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Virtuemart stt_cart
« Reply #1 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.