web design, England, Britain, UK, belgium
 

Virtuemart Cheat Sheet - Joomla & VirtueMart Tips & How To's

GJC Website Design UK, Joomla Developer, VirtueMart Developer, Template Developer, web site designs, England, Britain, UK, Belgium, search-engine optimisation (SEO). Multilingual.

Home Joomla VirtueMart Tips Virtuemart Cheat Sheet

Mon

28

Apr

Virtuemart Cheat Sheet
  • Virtuemart 2.0
  • Cheat Sheet

Here's a list of Virtuemart code snippets so that I don't have to search the forums every time I need one!

Virtuemart 2.0

Get cart object

if (!class_exists('VirtueMartCart')) require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
$cart = VirtueMartCart::getCart();
.......................................................

Get address in $cart

if($cart->STsameAsBT == 0){
    $address = (($cart->ST == 0 ) ? $cart->BT : $cart->ST);
    }else{
    $address = $cart->BT;
    }
.......................................................

Loop thru products in $cart

$Total_Length=array();
foreach ($cart->products as $product) {
     if($product->quantity){            #only if array contains values
          $Total_Length[].= $product->product_length;
      }
}

.......................................................

Get shopper Group

$userModel = VmModel::getModel('user');
$vmuser = $userModel->getCurrentUser();
$vmgroup = $vmuser->shopper_groups;
//is an array

.......................................................

<h3>Loop thru products in $cart</h3>
$Total_Length=array();<br />foreach ($cart-&gt;products as $product) {<br />     if($product-&gt;quantity){            #only if array contains values<br />          $Total_Length[].= $product-&gt;product_length;<br />      }<br />}<br />
<p>.......................................................</p>
Last Updated on Thursday, 09 April 2015 18:42
 
VirtueMart
Your Cart is currently empty.



Virtuemart Cheat Sheet|Joomla & VirtueMart Tips & How To's



GJC Website Design UK, Joomla Developer, VirtueMart Developer, Template Developer, web site designs, England, Britain, UK, Belgium, search-engine optimisation (SEO). Multilingual.


cart, product, length, array, total, products, address, virtuemart, quantity, foreach, virtuemartcart, values, usermodel, contains, vmuser, shopper, loop, getcurrentuser, groups, vmgroup, vmmodel, group, getmodel, user, getcart, don, search, forums, snippets, code, cheat, sheet, list, time, object, site, helpers, php, jpath, class

|

We use cookies to improve our website and your experience when using it. Cookies used for the essential operation of the site have already been set.
To find out more about the cookies we use and how to delete them, see our privacy policy.

I accept cookies from this site.