Hide "add to cart button" when brand-url is filled out

  • Posts: 344
  • Thank you received: 3
7 years 2 months ago #261042

-- HikaShop version -- : 3
-- Joomla version -- : 3.6.5
-- PHP version -- : 7

So iv'e used the code (below) and created a "buy now" button that links to external products (when I fill out brand url)

<input type="button" onclick="window.location='<?php echo $this->row->product_url; ?>'; return false;" value="buy now"/>

I placed it in the file product | quantity and it works perfect.

Anyway I have a question:

Is it possible to write aa php code to create a function that hide's the native "add to cart" button on the product page when the "brand URL" of the product is filled out ?

Would it be something like this
if($this->row->hikashop_product_url_main == 1)
{
$this->row->addtocartoption = 0;
}

?

Please Log in or Create an account to join the conversation.

  • Posts: 4519
  • Thank you received: 611
  • MODERATOR
7 years 2 months ago #261066

Hello,

In theory of course you can, but we need more context in order to better understand your needs, and maybe their is an HikaShop option that can fit your needs better than a custom code?

Awaiting news from you.

Regards

Last edit: 7 years 2 months ago by Philip.

Please Log in or Create an account to join the conversation.

  • Posts: 344
  • Thank you received: 3
7 years 2 months ago #261257

OK this is what my product page on my test-site looks like now.



When I paste a URL in the in the product "brand url" field the button "Gå til forhandler/Go to dealer" links to this url.

But now both button displays. I need the standard "add to cart" button to be HIDDEN when the product "brand url" is filled out

So that only the new button "go to dealer" displays.

NOTE: I know that I can use code to remove the standard "add to cart" button, but I have some products that I sell myself so I need it to display on these products.

Any advice on how two write code like that ?

tnx

How my explenation makes more sense. =)

Attachments:
Last edit: 7 years 2 months ago by river.

Please Log in or Create an account to join the conversation.

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
7 years 2 months ago #261260

Hi,

I suppose you could add such code at the top of the "quantity" view file:

<?php if(!empty($this->element->product_url)) return; ?>

Please Log in or Create an account to join the conversation.

  • Posts: 344
  • Thank you received: 3
7 years 2 months ago #261317

OK tnx for reply

This works ! Excellent.

Now the begining of my product | quantity file look like this

<input type="button" onclick="window.location='<?php echo $this->row->product_url; ?>'; return false;" value="Gå til forhandler!>"/><br/>
<?php if(!empty($this->element->product_url)) return; ?>
<?php
/**
 * @package	HikaShop for Joomla!
 * @version	3.0.0
 * @author	hikashop.com
 * @copyright	(C) 2010-2017 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

Is it possible to add another small function to this code.

Now both buttons are displaying when the "Brand url" is NOT filled out.

Is if possible to add code so that ONLY the "add to cart" but is displaying when the "Brand url" if NOT filled out ?

Last edit: 7 years 2 months ago by river.

Please Log in or Create an account to join the conversation.

  • Posts: 26007
  • Thank you received: 4004
  • MODERATOR
7 years 2 months ago #261322

Hi,

You should only display your custom code when the product_url is not fill.
It is simply an improvement of the content of the "if" that Nicolas gave you.

Even if it's basic PHP code ; I'm afraid that it is starting to become some custom code and we are starting to go outside of the limit of the HikaShop support.
I recommend you to read some articles in order to learn the base of PHP, so you will be able to move forward in your HikaShop customization.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 344
  • Thank you received: 3
7 years 2 months ago #261358

Tnx for reply

Yes I know that its a simple improvement of the content of the "if"

<input type="button" onclick="window.location='<?php echo $this->row->product_url; ?>'; return false;" value="Gå til forhandler!>"/><br/>
<?php if(!empty($this->element->product_url)) return; ?>
<?php

So does anyone else have some advice on what piece of code to add to the last code-sentence so it hides my custom button "Gå til forhandler/Go to dealer" when the "Brand URL" of the product is not filled.

?

Any advice would be GREATLY appreciated :)

Last edit: 7 years 2 months ago by river.

Please Log in or Create an account to join the conversation.

  • Posts: 26007
  • Thank you received: 4004
  • MODERATOR
7 years 2 months ago #261397

Hi,

Like I told you in my previous post, your request is more a request for "custom code" than support on HikaShop.
You want to modify the HikaShop view, change the behavior, the page of the content and the way that your website is "acting".
So it is going outside of the limit of our support.

Thank you for your understanding


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 344
  • Thank you received: 3
7 years 2 months ago #261447

OK I understad.

I will make a post under commerical jobs.

Please Log in or Create an account to join the conversation.

Time to create page: 0.087 seconds
Powered by Kunena Forum