Skip to content

Commit

Permalink
PALRES-205 Product not for sell - Will show price or not
Browse files Browse the repository at this point in the history
  • Loading branch information
lu.redweb committed May 5, 2017
1 parent f6ab758 commit d4aa109
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 13 deletions.
3 changes: 3 additions & 0 deletions component/admin/language/en-GB/en-GB.com_redshop.ini
Expand Up @@ -1695,6 +1695,9 @@ COM_REDSHOP_TOOLTIP_PRODUCT_EXPIRED_LBL="Product Expired"
COM_REDSHOP_PRODUCT_NOT_FOR_SALE="Product not for sell"
COM_REDSHOP_TOOLTIP_PRODUCT_NOT_FOR_SALE="Product Not For Sell"
COM_REDSHOP_TOOLTIP_PRODUCT_NOT_FOR_SALE_LBL="Product Not For Sell"
COM_REDSHOP_PRODUCT_NOT_FOR_SALE_SHOWPRICE="Product not for sell will show price?"
COM_REDSHOP_TOOLTIP_PRODUCT_NOT_FOR_SALE_SHOWPRICE="Product not for sell will show price?"
COM_REDSHOP_TOOLTIP_PRODUCT_NOT_FOR_SALE_SHOWPRICE_LBL="Product not for sell will show price?"
COM_REDSHOP_PRODUCT_PREORDER="Product Pre-Order"
COM_REDSHOP_TOOLTIP_PRODUCT_PREORDER="Select 'Yes' if you want your customers to be able to pre-order products."
COM_REDSHOP_TOOLTIP_PRODUCT_PRICE="Enter product price."
Expand Down
2 changes: 1 addition & 1 deletion component/admin/models/product.php
Expand Up @@ -173,7 +173,7 @@ public function _buildQuery()
}
elseif ($product_sort == 'p.not_for_sale')
{
$and = 'AND p.not_for_sale=1 ';
$and = 'AND p.not_for_sale > 0 ';
}
elseif ($product_sort == 'p.product_not_on_sale')
{
Expand Down
6 changes: 6 additions & 0 deletions component/admin/models/product_detail.php
Expand Up @@ -457,6 +457,12 @@ public function store($data)
JFile::upload($src, $dest);
}

// Product not for sell - Show price or not
if ($row->not_for_sale && $data['not_for_sale_showprice'])
{
$row->not_for_sale = 2;
}

$isNew = ($row->product_id > 0) ? false : true;

JPluginHelper::importPlugin('redshop_product');
Expand Down
65 changes: 56 additions & 9 deletions component/admin/views/product_detail/tmpl/default_general_data.php
Expand Up @@ -31,6 +31,26 @@ function (response) {
document.formvalidator.setHandler("productNumber", function (value) {
return !productNumber.contains(value);
});

if ($('input[name=not_for_sale]:checked').val() == 1)
{
$('#not_for_sale_showprice').show();
}
else
{
$('#not_for_sale_showprice').hide();
}

$('input[name=not_for_sale]').change(function () {
if ($(this).val() == 1)
{
$('#not_for_sale_showprice').show(500);
}
else
{
$('#not_for_sale_showprice').hide(500);
}
})
});
})(jQuery);
</script>
Expand Down Expand Up @@ -59,7 +79,8 @@ function (response) {

<div class="form-group">
<label for="product_number" id="product_number-lbl">
<?php echo JText::_('COM_REDSHOP_PRODUCT_NUMBER') ?><span class="star text-danger"> *</span>
<?php echo JText::_('COM_REDSHOP_PRODUCT_NUMBER') ?><span
class="star text-danger"> *</span>
<?php echo JHtml::tooltip(JText::_('COM_REDSHOP_TOOLTIP_PRODUCT_NUMBER'), JText::_('COM_REDSHOP_PRODUCT_NUMBER'), 'tooltip.png', '', '', false); ?>
</label>
<input class="form-control validate-productNumber"
Expand Down Expand Up @@ -87,6 +108,23 @@ function (response) {
<?php echo $this->lists['categories']; ?>
</div>

<div class="form-group">
<label for="product_type">
<?php echo JText::_('COM_REDSHOP_PRODUCT_TYPE'); ?>
<?php
echo JHtml::tooltip(
JText::_('COM_REDSHOP_PRODUCT_TYPE_TIP'),
JText::_('COM_REDSHOP_PRODUCT_TYPE'),
'tooltip.png',
'',
'',
false
);
?>
</label>
<?php echo $this->lists['product_type']; ?>
</div>

<div class="form-group">
<label for="product_template">
<?php echo JText::_('COM_REDSHOP_PRODUCT_TEMPLATE'); ?>
Expand Down Expand Up @@ -440,14 +478,6 @@ function (response) {
<?php echo $this->lists['supplier']; ?>
</div>

<div class="form-group">
<label for="product_type">
<?php echo JText::_('COM_REDSHOP_PRODUCT_TYPE'); ?>
<?php echo JHtml::tooltip(JText::_('COM_REDSHOP_PRODUCT_TYPE_TIP'), JText::_('COM_REDSHOP_PRODUCT_TYPE'), 'tooltip.png', '', '', false); ?>
</label>
<?php echo $this->lists['product_type']; ?>
</div>

<div class="form-group">
<label for="product_parent_id">
<?php echo JText::_('COM_REDSHOP_PARENT_PRODUCT'); ?>
Expand Down Expand Up @@ -519,6 +549,23 @@ function (response) {
<?php echo $this->lists['not_for_sale']; ?>
</div>

<div class="form-group" id="not_for_sale_showprice">
<label for="not_for_sale_showprice0">
<?php echo JText::_('COM_REDSHOP_PRODUCT_NOT_FOR_SALE_SHOWPRICE'); ?>
<?php
echo JHtml::tooltip(
JText::_('COM_REDSHOP_TOOLTIP_PRODUCT_NOT_FOR_SALE_SHOWPRICE'),
JText::_('COM_REDSHOP_TOOLTIP_PRODUCT_NOT_FOR_SALE_SHOWPRICE_LBL'),
'tooltip.png',
'',
'',
false
);
?>
</label>
<?php echo $this->lists['not_for_sale_showprice']; ?>
</div>

<div class="form-group">
<label for="preorder">
<?php echo JText::_('COM_REDSHOP_PRODUCT_PREORDER'); ?>
Expand Down
13 changes: 12 additions & 1 deletion component/admin/views/product_detail/view.html.php
Expand Up @@ -430,7 +430,18 @@ public function display($tpl = null)
$lists['copy_attribute'] = JHtml::_('select.booleanlist', 'copy_attribute', 'class="inputbox"', 0);
$lists['product_special'] = JHtml::_('select.booleanlist', 'product_special', 'class="inputbox"', $detail->product_special);
$lists['product_download'] = JHtml::_('select.booleanlist', 'product_download', 'class="inputbox"', $detail->product_download);
$lists['not_for_sale'] = JHtml::_('select.booleanlist', 'not_for_sale', 'class="inputbox"', $detail->not_for_sale);

$detail->not_for_sale_showprice = 0;

if ($detail->not_for_sale == 2)
{
$detail->not_for_sale = 1;
$detail->not_for_sale_showprice = 1;
}

$lists['not_for_sale'] = JHtml::_('select.booleanlist', 'not_for_sale', 'class="inputbox"', $detail->not_for_sale);
$lists['not_for_sale_showprice'] = JHtml::_('select.booleanlist', 'not_for_sale_showprice', 'class="inputbox"', $detail->not_for_sale_showprice);

$lists['expired'] = JHtml::_('select.booleanlist', 'expired', 'class="inputbox"', $detail->expired);
$lists['allow_decimal_piece'] = JHtml::_('select.booleanlist', 'allow_decimal_piece', 'class="inputbox"', $detail->allow_decimal_piece);

Expand Down
9 changes: 8 additions & 1 deletion component/site/helpers/producthelper.php
Expand Up @@ -3753,7 +3753,14 @@ public function getProductOnSaleComment($product = array(), $data_add = "")

public function getProductNotForSaleComment($product = array(), $data_add = "", $attributes = array(), $is_relatedproduct = 0, $seoTemplate = "")
{
if (!$product->not_for_sale)
$showPrice = true;

if ($product->expired || $product->not_for_sale == 1)
{
$showPrice = false;
}

if ($showPrice)
{
// Product show price without formatted
$applytax = $this->getApplyVatOrNot($data_add);
Expand Down
2 changes: 1 addition & 1 deletion component/site/models/cart.php
Expand Up @@ -552,7 +552,7 @@ public function redmasscart($post)
continue;
}

if ($product->not_for_sale == 1)
if ($product->not_for_sale > 0)
{
$msg = sprintf(JText::_('COM_REDSHOP_PRODUCT_IS_NOT_FOR_SALE'), $product->product_name, $product_id);
JError::raiseWarning(20, $msg);
Expand Down

0 comments on commit d4aa109

Please sign in to comment.