News:

Support the VirtueMart project and become a member

Main Menu

productsnapshot allows add to cart even in no prices mode

Started by unleash.it, October 04, 2008, 10:20:09 AM

Previous topic - Next topic

unleash.it

I'm working on website that uses the feature to hide prices from non-registered users. The site has a Specials page (normal Joomla article) that uses productsnapshot, and it works fine. But when I choose "show add to cart" in the plugin parameters, add to cart shows up regardless of if anyone is logged in or not.

Correct me if I'm wrong, but shouldn't this add to cart be hidden to guests (and of course the whole checkout process) as it is on regular virtuemart pages? When you click on it, it really does add to cart and the prices are displayed. Ideally it would be nice to have add to cart appear for registered users but disappear for guests.

skyline

The Product Snap shot does 0 checks for that sort of thing.

Moreover, it does not post the information as Form Data.(Like a regular Product) But rather it just creates a URL with the Params.

So it will call Add to cart regardless of what setting you have in Vmart.

It's pretty stand alone in nature.
I would look into editing the Product Snapshot Mambot. It's pretty basic and consists of one page. You can really do some cool stuff with customizing it.

HTH



unleash.it

Thank's Skyline for your answer. Yes I have edited the plugin a bit and I think I can figure out how to hide the add to cart if the user is a guest. But... don't you agree that it makes no sense that it's this way by default?

Actually, it does do a check for user, at least for the price. If the "show prices" feature is turned on in the back end, you will see the text "you must be logged in..." for prices. But the add to cart text does appear.

Unless there's a good reason, I would think it's an oversight...with a pretty easy fix. I would offer the fix, but I am a hack as a programmer at best.

skyline

Yes I agree, my opinion has been that the product snapshot feels like it was done as an aside and grew into a commonly used piece.

You should post it anyway with a simple Change line #

From:

"some line of code"

To This:

"New Line of Code"

It may help some one. I am not an elegant Programmer but no one has bitten my head off for posting the stuff I have changed.

Cheers

unleash.it

#4
Ok, here it is:

After line 261 insert:

$userattr=JFactory::getUser();
$thisuser = $userattr ->get('aid');


then change 262 (it's now 264) to:

if( 'y' == $params['showaddtocart'] && $thisuser >= 1) {

That should fix the problem with add to cart. One other problem I am still not able to solve though...

Without needing this fix, the price itself is properly hidden when a user isn't logged in. The text from the language file is there instead: "You must be logged in and have an active account to purchase this product." But when you click on it, it takes you to the "ask seller a question" form. Very strange. Unfortunatly, I have no idea where the code for the link output is found. It appears that there is a hidden function somewhere that is controlling it...?

skyline

Good Deal,

I am not sure about the problem you're still having though.

I would track it down using grep. A lot of windows users are unfamiliar with grep as it is a native Unix command.

Basically, you can put in the words "Ask the seller a question" and it will search through the files in a folder looking for this string.

Think of it as a search within the files and use this tool to track down anything that you think may be hidden in some obscure function.

For windows users there is a tool called wingrep that is paramount in looking for stuff. I also suggest winmerge as it will let you compare 2 files and highlight the differences.

Just some handy tools.

I use sef advanced as my Sef solution for vmart and had to add functionality for support of the Product Snapshot. Here is a link to that if you ever need it.

http://www.sakic.net/forum/sef_advance/virtuemart_productsnapshot_support_for_virtuemart_extention-t783.0.html










unleash.it

Thanks again for your tips skyline. I didn't think of using a grep on this, but it's a good idea. I use Dreamweaver, which has a pretty decent one. We'll see how tricky it is... That same language string is used in a number of places.

Anyways, it's almost there for me, but I've placed a bug report so hopefully it gets fixed in the core.

As for SEF, I'll keep that in mind but I really like sh404SEF. At this stage, I have sef turned off so I don't think it's related.