Limit period

  • Posts: 7
  • Thank you received: 0
  • Hikamarket Multivendor Hikashop Business
7 months 3 weeks ago #288811

-- HikaShop version -- : 3.3.0
-- Joomla version -- : 3.8.5
-- PHP version -- : 7.0

When using the "Limit" feature is it possible to add bi-weekly and every 3 weeks to the drop down?

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

  • Posts: 63629
  • Thank you received: 9166
  • MODERATOR
7 months 3 weeks ago #288826

Hi,

There is no option to add more choices to it.
To do that you would have to:
- modify the code:

$periodicity = array(
			'forever' => 0,
			'yearly' => 1,
			'quarterly' => 2,
			'monthly' => 3,
			'weekly' => 4,
			'daily' => 5,
			'cart' => 6
		);
		$baseDates = array(
			0 => 0,
			1 => mktime(0,0,0,1,1,$d['year']),
			2 => mktime(0,0,0,$d['mon']-(($d['mon']-1)%4),1,$d['year']),
			3 => mktime(0,0,0,$d['mon'],1,$d['year']),
			4 => mktime(0,0,0,$d['mon'],$d['mday']-$d['wday'],$d['year']),
			5 => mktime(0,0,0,$d['mon'],$d['mday'],$d['year']),
			6 => -1
		);
in the file administrator/components/com_hikashop/classes/limit.php to add the new choices in the code which process the limits.
- Edit the file administrator/components/com_hikashop/views/limit/tmpl/form.php and add the new choices in the code below to add them to the dropdown of limits:
								$values = array();
								$values[] = JHTML::_('select.option', 'cart', JText::_('Cart'));
								$values[] = JHTML::_('select.option', 'daily', JText::_('Daily'));
								$values[] = JHTML::_('select.option', 'weekly', JText::_('Weekly'));
								$values[] = JHTML::_('select.option', 'monthly', JText::_('Monthly'));
								$values[] = JHTML::_('select.option', 'quarterly', JText::_('Quarterly'));
								$values[] = JHTML::_('select.option', 'yearly', JText::_('Yearly'));
								$values[] = JHTML::_('select.option', 'forever', JText::_('Forever'));
								echo JHTML::_('select.genericlist', $values, "data[limit][limit_periodicity]" , 'class="inputbox" size="1"', 'value', 'text', @$this->element->limit_periodicity );

The following user(s) said Thank You: piggersisdaman

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

  • Posts: 7
  • Thank you received: 0
  • Hikamarket Multivendor Hikashop Business
7 months 3 weeks ago #288846

I added 2 more options and they appear in the drop down menu fine. On the limit.php, it doesn't appear to be working correctly. I tested it and it using the 2 new options and it still allows it to be added to cart without warning.

Is it possible my mktime is incorrect for array 7 and 8?

Thanks for help.

$d = getdate();
		$periodicity = array(
			'forever' => 0,
			'yearly' => 1,
			'quarterly' => 2,
			'monthly' => 3,
			'weekly' => 4,
			'daily' => 5,
			'cart' => 6,
			'bi-weekly' => 7,
			'three-weeks' => 8
		);
		$baseDates = array(
			0 => 0,
			1 => mktime(0,0,0,1,1,$d['year']),
			2 => mktime(0,0,0,$d['mon']-(($d['mon']-1)%4),1,$d['year']),
			3 => mktime(0,0,0,$d['mon'],1,$d['year']),
			4 => mktime(0,0,0,$d['mon'],$d['mday']-$d['wday'],$d['year']),
			5 => mktime(0,0,0,$d['mon'],$d['mday'],$d['year']),
			6 => -1,
			7 => mktime(0,0,0,$d['mon'],$d['mday']-13,$d['year']),
			8 => mktime(0,0,0,$d['mon'],$d['mday']-20,$d['year'])
			
		);

Last Edit: 7 months 2 weeks ago by piggersisdaman.

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

  • Posts: 7
  • Thank you received: 0
  • Hikamarket Multivendor Hikashop Business
7 months 3 weeks ago #288847

I spotted my mistake. I dropped 7 and 8 below 6.

$d = getdate();
		$periodicity = array(
			'forever' => 0,
			'yearly' => 1,
			'quarterly' => 2,
			'monthly' => 3,
			'weekly' => 4,
			'daily' => 5,
			'cart' => 6,
			'bi-weekly' => 7,
			'three-weeks' => 8
		);
		$baseDates = array(
			0 => 0,
			1 => mktime(0,0,0,1,1,$d['year']),
			2 => mktime(0,0,0,$d['mon']-(($d['mon']-1)%4),1,$d['year']),
			3 => mktime(0,0,0,$d['mon'],1,$d['year']),
			4 => mktime(0,0,0,$d['mon'],$d['mday']-$d['wday'],$d['year']),
			5 => mktime(0,0,0,$d['mon'],$d['mday'],$d['year']),
			6 => -1,
			7 => mktime(0,0,0,$d['mon'],$d['mday']+13,$d['year']),
			8 => mktime(0,0,0,$d['mon'],$d['mday']+20,$d['year'])
		);

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

Time to create page: 0.081 seconds
Powered by Kunena Forum