64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
|
|
use_helper('stAvailabilityImage');
|
|
|
|
function st_availability_show(Product $product)
|
|
{
|
|
$availability = $product->getFrontendAvailability();
|
|
|
|
if (!$availability)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
$imgage = '';
|
|
|
|
$label = $availability->getAvailabilityName();
|
|
|
|
|
|
if ($availability->getOptImage())
|
|
{
|
|
$image = st_availability_image_tag($availability, 'full');
|
|
}
|
|
|
|
return $image.'<span class="product-availability-label">'.$label.'</span>';
|
|
}
|
|
|
|
function st_availability_backend_label(Product $product)
|
|
{
|
|
$availabilities = AvailabilityPeer::doSelectCached();
|
|
|
|
return isset($availabilities[$product->getAvailabilityId()]) ? $availabilities[$product->getAvailabilityId()]->getAvailabilityName() : __('Ustaw według magazynu', null, 'stProduct');
|
|
}
|
|
|
|
function st_availability_select_tag($name, $value, array $options = array())
|
|
{
|
|
$selectParameters = [];
|
|
|
|
if (isset($options['include_custom']))
|
|
{
|
|
$selectParameters['include_custom'] = $options['include_custom'];
|
|
unset($options['include_custom']);
|
|
}
|
|
|
|
if (isset($options['exclude_default_stock']) && $options['exclude_default_stock'])
|
|
{
|
|
$selectOptions = AvailabilityPeer::doSelectCached();
|
|
unset($options['exclude_default_stock']);
|
|
}
|
|
else
|
|
{
|
|
$selectOptions = array(0 => __('Ustaw według magazynu', null, 'stProduct')) + AvailabilityPeer::doSelectCached();
|
|
}
|
|
|
|
return select_tag($name, options_for_select($selectOptions, $value, $selectParameters), $options);
|
|
}
|
|
|
|
function object_st_availability_select_tag($object, $method, $options = array(), $default_value = null)
|
|
{
|
|
$options = _parse_attributes($options);
|
|
$value = _get_object_value($object, $method, $default_value);
|
|
$name = _convert_method_to_name($method, $options);
|
|
|
|
return st_availability_select_tag($name, $value, $options);
|
|
} |