Hi,
please is there a way to set closing times for eshop - e.g.when you use VM to sell pizza, and you want to disable orders from e.g. 10 pm to 9am... and people should not be able to put anything into cart...without switching to catalogue manually...
and instead show some message - we're closed now, come back tomorrow at...
I guess you are using latest VirtueMart 3. If that is correct then you can customize the add to cart button sub-layout with a HTML override in your template.
Copy components/com_virtuemart/sublayouts/addtocartbtn.php to templates/your_joomla_template/html/com_virtuemart/sublayouts/addtocartbtn.php
Now open templates/your_joomla_template/html/com_virtuemart/sublayouts/addtocartbtn.php
Find the following codes between lines 17 to 21:
if($viewData['orderable']) {
echo '<input type="submit" name="addtocart" class="addtocart-button" value="'.vmText::_( 'COM_VIRTUEMART_CART_ADD_TO' ).'" title="'.vmText::_( 'COM_VIRTUEMART_CART_ADD_TO' ).'" />';
} else {
echo '<span name="addtocart" class="addtocart-button-disabled" title="'.vmText::_( 'COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT' ).'" >'.vmText::_( 'COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT' ).'</span>';
}
Replace above by:
$date = JFactory::getDate();
$opening_hour = 09; // 9 am
$closing_hour = 22; // 10 pm
$current_hour = $date->format('H');
if($current_hour < $opening_hour || $current_hour > $closing_hour)
{
echo '<div style="font-weight: bold;">We are closed now, come back tomorrow at 9:00 am</div>';
}
else
{
if($viewData['orderable'])
{
echo '<input type="submit" name="addtocart" class="addtocart-button" value="'.vmText::_( 'COM_VIRTUEMART_CART_ADD_TO' ).'" title="'.vmText::_( 'COM_VIRTUEMART_CART_ADD_TO' ).'" />';
}
else
{
echo '<span name="addtocart" class="addtocart-button-disabled" title="'.vmText::_( 'COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT' ).'" >'.vmText::_( 'COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT' ).'</span>';
}
}