sitemap  |  contact

Sakic.Net Forum
21 November 2008, 09:18 *
Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length
News: Email Directory goes free: http://www.sakic.net/products/free_products/
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Virtuemart Productsnapshot support for Virtuemart extention  (Read 407 times)
skyline
Newbie
*
Posts: 4


View Profile
« on: 02 September 2008, 22:37 »

I don't know if anyone is using the product snapshot with virtuemart but I noticed that the sef 3rd party ext doesn't handle it.

If you need it, here is how to get it working.
Thanks Emir for writing the extention in the first place!!!

ALWAYS BACKUP YOUR FILES AND RUN EVERYTHING ON A TEST SERVER BEFORE MAKING CHANGES>

Using the sef_ext for Vmart 1.1
insert  this on line 22
define('_VM_CARTADD', 'addtocart');

Change Elseif on line 180 from:
      } else if (eregi("page=shop.cart",$string)) {
         // cart
         $sefstring = sefencode(_VM_CART);
         $sefstring .= '/';

TO:
      } else if (eregi("page=shop.cart",$string)) {      
         // cart handle add to function for Vmart mambot
         if (eregi("func=cartadd",$string)) {
         $sefstring .= sefencode(_VM_CART);
         $sefstring .= '/';   
         $sefstring .= sefencode(_VM_CARTADD);
         $sefstring .= '/';
         $temp = split('&product_id=', $string);
         $temp = split('&', $temp[1]);
         $pid = $temp[0];
         $database->setQuery( "SELECT product_name FROM #__".SEF_VM_TABLEPREFIX."_product WHERE product_id = '" . $pid . "'" );
         $prod = sefencode($database->loadResult());
         $sefstring .= $prod;
         $sefstring .= '/';

      } else {
         // cart   
         $sefstring = sefencode(_VM_CART);
         $sefstring .= '/';}

Feel Free to make this a little cleaner but that will take care of the func for add to cart used by the product snap in the url and basically add the string with just the product ID.

Now we just change the revert function to send it to the right place.

Change the ElseIf on line 276 From:

       } else if (isset($url_array[$pos+2]) && $url_array[$pos+2]==sefencode(_VM_CART)) {
         $page = $_GET['page'] = $_REQUEST['page'] = 'shop.cart';
         $nonsefstring .= 'page=' . $page;


TO:
       } else if (isset($url_array[$pos+2]) && $url_array[$pos+2]==sefencode(_VM_CART)) {
           //handle cart with add to cart
         if (isset($url_array[$pos+2]) && $url_array[$pos+3]==sefencode(_VM_CARTADD)) {
         $product_name = sefdecode($url_array[$pos+4]);         
         $database->setQuery( "SELECT product_id FROM #__".SEF_VM_TABLEPREFIX."_product WHERE product_name = '" . $product_name . "'" );
         $prod = $database->loadResult();
         $page = $_GET['page'] = $_REQUEST['page'] = 'shop.cart';
         $func =  $_GET['func'] = $_REQUEST['func'] = 'cartADD';
         $product_id = $_GET['product_id'] = $_REQUEST['product_id'] = $prod;
         $nonsefstring .= 'page=' . $page . '&func' . $func . '&product_id=' . $product_id;
         } else {
         //handle just cart
         $page = $_GET['page'] = $_REQUEST['page'] = 'shop.cart';
         $nonsefstring .= 'page=' . $page; }

This will allow the Product Snapshot to add to cart. This can also be cleaned up and feel free to do so.

Thanks Emir for making it easy to modify these extentions so we can quickly support things that we decide to use.

HTH someone





Logged
Saka
Administrator
Hero Member
*****
Posts: 1,293


View Profile WWW
« Reply #1 on: 02 September 2008, 22:52 »

Thanks. What this forum misses is more posts like yours where users help other users, and less specific support questions (that's done by email).
Logged

Pages: [1]
  Print  
 
Jump to: