Hide Parameter if Product sale date in future

  • Posts: 303
  • Thank you received: 18
5 years 10 months 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: 5 years 10 months ago by mojooutdoors-holden.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
5 years 10 months 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: 303
  • Thank you received: 18
5 years 10 months 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.061 seconds
Powered by Kunena Forum