News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

[VM3] Hide add to cart option to unregistered?

Started by Alexanderz, March 03, 2016, 10:30:15 AM

Previous topic - Next topic

Alexanderz

Hi, use the latest version of VM 3.0.13.6 and wanted to know if there was a way like in V2 to hide the "add to cart" to those who were not registered, including by changing the module itself.

Thank you

P.S. I think, it is a function that should be integrated natively in VM3. It is very important for many sellers.

GJC Web Design

std. user check snippet in the cart   display..  over ride components\com_virtuemart\sublayouts\addtocartbar.php

$user = JFactory::getUser();   
  $user_id = $user->get('id');   


if (!VmConfig::get('use_as_catalog', 0) && $userid != 0 ) { ?>
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

jenkinhill

Quote from: Alexanderz on March 03, 2016, 10:30:15 AM
It is very important for many sellers.

Almost every VirtueMart site I have worked on does not use customer registration at all, but as GJC says, it just takes a simple template override to provide this function.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Alexanderz

#3
thanks for the answer, but it seems not work.
I created an override in mytemplates/html/com_virtuemart/sublayouts/addtocartbar.php

add :
$user = JFactory::getUser();
$user_id = $user->get('id');

and replace:


if (!VmConfig::get('use_as_catalog', 0)  ) { ?> in
if (!VmConfig::get('use_as_catalog', 0) && $userid != 0 ) { ?>

Here is the php source --> http://pastie.org/10746389


GJC Web Design

if (!VmConfig::get('use_as_catalog', 0) && $user_id != 0 ) { ?>
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Alexanderz


GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

Hi Alexanderz,
Have you check if your template do not overide it?
Some do not use the sublayouts, so changing the code here do not remove the add to cart render.

Alexanderz

hi Studio 42
Yes, I also tried to change the component itself, without using overide, but does not work the same.

in homepage of my site under "Session" of debug, I see this:

index.php?option=com_virtuemart&view=virtuemart&productsublayout=0

⇒{"__default":{"session":{"counter":6,"timer":{"start":1457090728,"last":1457091067,"now":1457091177},"token":"40417277850c8601ad1d2cca089f2ce4"},"registry":{"separator":"."},"user":{"id":0,"name":null,"username":null,"email":null,"password":null,"password_clear":"","block":null,"sendEmail":0,"registerDate":null,"lastvisitDate":null,"activation":null,"params":null,"groups":["9"],"guest":1,"lastResetTime":null,"resetCount":null,"requireReset":null,"aid":0}},"__easycalccheck":{"redirect_url":null,"hidden_class":"es8tzs2re7l","spamcheck":"omfcimpwpd93","rot13":1,"spamcheckresult":"ZGp=","time":1457091068,"ip":"87.20.177.198"},"__vm":{"manage":0,"vmlastvisitedItemid":134,"vmcart":"{\"cartProductsData\":[{\"virtuemart_product_id\":10,\"quantity\":1,\"customProductData\":[]}],\"vendorId\":1,\"lastVisitedCategoryId\":0,\"virtuemart_shipmentmethod_id\":\"5\",\"virtuemart_paymentmethod_id\":0,\"automaticSelectedShipment\":true,\"automaticSelectedPayment\":false,\"order_number\":null,\"BT\":0,\"ST\":0,\"cartfields\":null,\"couponCode\":\"\",\"_triesValidateCoupon\":[],\"order_language\":\"it-IT\",\"pricesCurrency\":182,\"paymentCurrency\":null,\"_guest\":1,\"_inCheckOut\":false,\"_inConfirm\":false,\"_dataValidated\":false,\"_confirmDone\":false,\"STsameAsBT\":1,\"selected_shipto\":0,\"_fromCart\":false,\"layout\":\"default\",\"layoutPath\":\"\",\"virtuemart_cart_id\":0}","vmlastvisitedcategoryid":0,"vmlastvisitedmanuid":0}}

Studio 42

WHy you don't dump the use_id?
<php var_dump($user->get('id')) ?>
So you can check if you are in the good file and that the value change.
Another problem can be that you use page cache in Joomla ?

Alexanderz

How can I dump the user_id?

I deleted the Joomla cache but still does not work.
thank you.

Jörgen

Quote from Patrick
WHy you don't dump the use_id?
<php var_dump($user->get('id')) ?>


regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Milbo

Quote from: Studio 42 on March 04, 2016, 13:03:33 PM
WHy you don't dump the use_id?
<php var_dump($user->get('id')) ?>

Please use vmdebug('my stuff',$user);
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Alexanderz


Studio 42

#14
Quote from: Milbo on March 04, 2016, 14:42:44 PM
Quote from: Studio 42 on March 04, 2016, 13:03:33 PM
WHy you don't dump the use_id?
<php var_dump($user->get('id')) ?>

Please use vmdebug('my stuff',$user);
Or echo, this is not the problem.

YOu said, you have change codes but don't know how to add a var_dump or echo, print_r ...?
So please read the PHP Doc to know some elementary function , else we cannot help you.
We can help you, but we don't work for you ;)