Virtuemart Productsnapshot support for Virtuemart extention
- skyline
-
Topic Author
- Offline
- New Member
-
Less
More
- Thank you received: 0
16 years 7 months ago #3267
by skyline
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 = $_REQUEST = '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 = $_REQUEST = 'shop.cart';
$func = $_GET = $_REQUEST = 'cartADD';
$product_id = $_GET = $_REQUEST = $prod;
$nonsefstring .= 'page=' . $page . '&func' . $func . '&product_id=' . $product_id;
} else {
//handle just cart
$page = $_GET = $_REQUEST = '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
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 = $_REQUEST = '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 = $_REQUEST = 'shop.cart';
$func = $_GET = $_REQUEST = 'cartADD';
$product_id = $_GET = $_REQUEST = $prod;
$nonsefstring .= 'page=' . $page . '&func' . $func . '&product_id=' . $product_id;
} else {
//handle just cart
$page = $_GET = $_REQUEST = '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
Please Log in or Create an account to join the conversation.
- Saka
-
- Offline
- Administrator
-
16 years 7 months ago #3270
by Saka
Emir Sakic
www.sakic.net
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).
Emir Sakic
www.sakic.net
Please Log in or Create an account to join the conversation.