Hide Parameter if Product sale date in future

  • Posts: 206
  • Thank you received: 12
  • Hikashop Business
4 months 2 days ago #302854

-- HikaShop version -- : 3.5.1

I'm trying to conditionally hide a container if the product_sale_start > current date. I should also note, I'm trying to use this on the product/show_default view file.

I tried to mimic what was on the product/quantity view

<?php
$now = time();
$start_date = (@$this->row->product_sale_start || empty($this->element->main)) ? @$this->row->product_sale_start : $this->element->main->product_sale_start;
$end_date = (@$this->row->product_sale_end || empty($this->element->main)) ? @$this->row->product_sale_end : $this->element->main->product_sale_end;?>
<div style ="<?php if($start_date > 0 && $start_date > $now) echo "display:none";?>">
</div>
<?php
?>

However, it seems like it's not pulling the product_sale_start data at all? Any thoughts?

Last edit: 4 months 2 days ago by mojooutdoors-holden.

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

  • Posts: 65706
  • Thank you received: 9590
  • MODERATOR
4 months 1 day ago #302865

Hi,

Such code should be enough:

<div style ="<?php if($this->element->product_sale_start > time()) echo "display:none";?>">
</div>

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

  • Posts: 206
  • Thank you received: 12
  • Hikashop Business
4 months 1 day ago #302909

Ah, I was complicating matters. Thanks for the fix!

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

Time to create page: 0.052 seconds
Powered by Kunena Forum