- Posts: 490
- Thank you received: 2
how to disable add to cart button on certain field
-- Joomla version -- : 3.4.3
-- PHP version -- : 5.5
-- Error-message(debug-mod must be tuned on) -- : none
hi
how can i disable the add to cart field based on a custom field? and where exactly to place it? i have seeb add_to_cart_listing.php but not sure if this is the right one.
Example:
custom_field_add2cart = on =1
custom_field_add2cart = off =0
<?php
if($this->row->custom_field == 1)
{
$this->params->set('add_to_cart', 0);
}
else
{
$this->params->set('add_to_cart',$oldAddToCartParameter);
}
thanks
Please Log in or Create an account to join the conversation.
I would add it at the top of the "quantity" view file with such code:
Please Log in or Create an account to join the conversation.
its working.
but the other way around. if i set it to 1 = yes = $this->params->set('catalogue', 1); = add to cart is disabled
if i set it to 0 = no = $this->params->set('catalogue', 0); = add to cart is enabled
this is the behavior of the code above. is that correct?
thanks
Please Log in or Create an account to join the conversation.
If you want it the other way around, just change the :
if($this->row->custom_field == 1)
to:
if($this->row->custom_field == 0)
Please Log in or Create an account to join the conversation.
how can we retain add to wish list.
i just want to remove add to cart.
Also how do i update all the values of the other products that has been created before. can i use mass action?
this is my settings. I got it to work but not all products are affected. Do i need to increase the limatations field?
thanks
Please Log in or Create an account to join the conversation.
1. Then, instead of :
$this->params->set('catalogue', 1);
you can use :
$this->row->quantity = 0;
Actually, you could remove the customization and the custom field and just set the stock to 0 for the products for which you don't want the add to cart button but still want the wishlist.
2. You don't want a trigger or a filter in your mass action. Just have the action, and click on the "proceed" button. Also, note that it will only process the first 500 products you have. So you'll have to change the limitations area to process the other products after that.
Please Log in or Create an account to join the conversation.
1. it doesn't work if i try to replace this code
$this->params->set('catalogue', 1);
with this one
$this->row->quantity = 0;
i cant set the stock to 0 because my site is a multivendor site. Vendors have control over the stock of their products.
thanks
Please Log in or Create an account to join the conversation.
Changing dynamically the variable won't update the stock in the database.
It will not affect really the product and won't generate issue with HikaMarket.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
1. sorry i dont understand the last post.
i just want to display the add to wishlist button even do im using the custom code.
it doesn't work if i try to replace this code
$this->params->set('catalogue', 1);
with this one
$this->row->quantity = 0;
2. i tried to set the quantity in the back end to 0 and what you are saying worked. the add to cart is gone and the wishlist remained. unfortunately if the vendor changes the quantity the add to cart button appears again. I cant let the vendor control the add to cart button
thank you very much
Please Log in or Create an account to join the conversation.
Jerome was just saying that using the code which set the quantity to 0 is a great idea in that case.
I don't see why it wouldn't work.
Could you provide a copy of the whole code in the view file ?
Please Log in or Create an account to join the conversation.
this is working. but the add to wishlist button is gone. how do i make this work?
i tried this. it doesnt work. both wishlist and cart appears
thanks
Please Log in or Create an account to join the conversation.
Could you provide a copy of the whole code in the view file ?
Please Log in or Create an account to join the conversation.
here it os
thanks
Please Log in or Create an account to join the conversation.
Instead of:
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
You gave information about product listing ; not the product page.and provide a link to the product page where that doesn't work with a screenshot of the settings of that product ?
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
I will guide you, first, Nicolas ask you the product page with the issue, and not the listing page (we understand that maybe the product is among the listing, but the complete product page url will able us to be sure of what we do)
Ex : YOURWEBSITE/store/product/product-name
And for the screenshot of that product, we need this :
Reach it, Components => HikaShop => Products, and click on the product name (with issue) to see his configuration screen.
Awaiting news from you
Regards
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
So I suppose that the problem is that you're not using 1 and 0 as the values of your custom field. Which explains why it never goes in the else of the condition.
Can you provide a screenshot of the settings of your custom field ?
Please Log in or Create an account to join the conversation.