Jump to content

Specific Prices edit


Recommended Posts

  • 1 month later...

You can enable this function by override/modify some file :

 

Override : /override/controllers/admin/AdminProductsController.php - Add :

 

public function processPricesModification()
{
 // Check if a specific price has been submitted
 if (!Tools::getIsset('submitPriceEdition'))
  return;

 $id_product = Tools::getValue('id_product');

 $id_specific_prices = Tools::getValue('spm_id_specific_price');
 $id_combinations = Tools::getValue('spm_id_product_attribute');
 $id_shops = Tools::getValue('spm_id_shop');
 $id_currencies = Tools::getValue('spm_id_currency');
 $id_countries = Tools::getValue('spm_id_country');
 $id_groups = Tools::getValue('spm_id_group');
 $id_customers = Tools::getValue('spm_id_customer');
 $prices = Tools::getValue('spm_price');
 $from_quantities = Tools::getValue('spm_from_quantity');
 $reductions = (float)Tools::getValue('spm_reduction');
 $reduction_types = !$reductions ? 'amount' : Tools::getValue('spm_reduction_type');
 $froms = Tools::getValue('spm_from');
 if (!$froms)
  $froms = '0000-00-00 00:00:00';
 $tos = Tools::getValue('spm_to');
 if (!$tos)
  $tos = '0000-00-00 00:00:00';

 if ($this->_validateSpecificPrice($id_shops, $id_currencies, $id_countries, $id_groups, $id_customers, $prices, $from_quantities, $reductions, $reduction_types, $froms, $tos, $id_combinations))
 {
  $specific_price = new SpecificPrice((int)($id_specific_prices));
  $specific_price->id_shop = (int)$id_shops;
  $specific_price->id_product_attribute = (int)$id_combinations;
  $specific_price->id_currency = (int)($id_currencies);
  $specific_price->id_country = (int)($id_countries);
  $specific_price->id_group = (int)($id_groups);
  $specific_price->id_customer = (int)$id_customers;
  $specific_price->price = (float)($prices);
  $specific_price->from_quantity = (int)($from_quantities);
  $specificPrice->reduction = (float)($reduction_types == 'percentage' ? $reductions / 100 : $reductions);
  $specificPrice->reduction_type = $reduction_types;
  $specific_price->from = $froms;
  $specific_price->to = $tos;
  if (!$specific_price->update())
$this->errors = Tools::displayError('An error occurred while updating the specific price.');
 }

 if (!count($this->errors))
  $this->redirect_after = self::$currentIndex.'&id_product='.(int)(Tools::getValue('id_product')).(Tools::getIsset('id_category') ? '&id_category='.(int)Tools::getValue('id_category') : '').'&update'.$this->table.'&action=Prices&token='.$this->token;
}
public function ajaxProcessEditSpecificPrice()
{
 $specificPrice = null;
 $id_specific_price = (int)Tools::getValue('id_specific_price');
 if (!$id_specific_price || !Validate::isUnsignedId($id_specific_price))
  $error = Tools::displayError('Invalid specific price ID');
 else
 {
  $specificPrice = new SpecificPrice((int)$id_specific_price);
 }

 if (isset($error))
  $json = array(
'status' => 'error',
'message'=> $error
  );
 else
  $json = array(
'status' => 'ok',
'message'=> array(get_object_vars($specificPrice))
  );
 die(Tools::jsonEncode($json));
}
protected function _validateSpecificPrice($id_shop, $id_currency, $id_country, $id_group, $id_customer, $price, $from_quantity, $reduction, $reduction_type, $from, $to, $id_combination = 0)
{
 if (!Validate::isUnsignedId($id_shop) || !Validate::isUnsignedId($id_currency) || !Validate::isUnsignedId($id_country) || !Validate::isUnsignedId($id_group) || !Validate::isUnsignedId($id_customer))
  $this->errors[] = Tools::displayError('Wrong IDs');
 elseif ((!isset($price) && !isset($reduction)) || (isset($price) && !Validate::isNegativePrice($price)) || (isset($reduction) && !Validate::isPrice($reduction)))
  $this->errors[] = Tools::displayError('Invalid price/discount amount');
 elseif (!Validate::isUnsignedInt($from_quantity))
  $this->errors[] = Tools::displayError('Invalid quantity');
 elseif ($reduction && !Validate::isReductionType($reduction_type))
  $this->errors[] = Tools::displayError('Please select a discount type (amount or percentage)');
 elseif ($from && $to && (!Validate::isDateFormat($from) || !Validate::isDateFormat($to)))
  $this->errors[] = Tools::displayError('Wrong from/to date');
 /*elseif (SpecificPrice::exists((int)$this->object->id, $id_combination, $id_shop, $id_group, $id_country, $id_currency, $id_customer, $from_quantity, $from, $to, false))
  $this->errors[] = Tools::displayError('A specific price already exists for these parameters');*/
 else
  return true;
 return false;
}

 


 

Override : /override/controllers/admin/templates/products/prices.tpl - change as this :

 

<h4>{l s='Specific prices'}</h4>
<div class="hint" style="display:block;min-height:0;">
 {l s='You can set specific prices for clients belonging to different groups, different countries, etc.'}
</div>
<br />
<a class="button bt-icon" href="#" id="show_specific_price"><img src="../img/admin/add.gif" alt="" /><span>{l s='Add a new specific price'}</span></a>
<a class="button bt-icon" href="#" id="hide_specific_price" style="display:none"><img src="../img/admin/cross.png" alt=""/><span>{l s='Cancel new specific price'}</span></a>
<!-- ADD THIS BUTTON -->
<a class="button bt-icon" href="#" id="hide_edit_specific_price" style="display:none"><img src="../img/admin/cross.png" alt=""/><span>{l s='Cancel edit specific price'}</span></a>
...

 

And after :

<div id="add_specific_price" style="display: none;">
...
...
</div>

 

Add :

<div id="edit_specific_price" style="display: none;">
 <label>{l s='For:'}</label>
 {if !$multi_shop}
  <div class="margin-form">
<input type="hidden" name="spm_id_shop" value="0" />
 {else}
  <div class="margin-form">
<select name="spm_id_shop" id="spm_id_shop">
 {if !$admin_one_shop}<option value="0">{l s='All shops'}</option>{/if}
 {foreach from=$shops item=shop}
  <option value="{$shop.id_shop}">{$shop.name|htmlentitiesUTF8}</option>
 {/foreach}
</select>
   >
 {/if}
  <select name="spm_id_currency" id="spm_currency_1" onchange="changeCurrencySpecificPrice(1);">
<option value="0">{l s='All currencies'}</option>
{foreach from=$currencies item=curr}
 <option value="{$curr.id_currency}">{$curr.name|htmlentitiesUTF8}</option>
{/foreach}
  </select>
  >
  <select name="spm_id_country" id="spm_id_country">
<option value="0">{l s='All countries'}</option>
{foreach from=$countries item=country}
 <option value="{$country.id_country}">{$country.name|htmlentitiesUTF8}</option>
{/foreach}
  </select>
  >
  <select name="spm_id_group" id="spm_id_group">
<option value="0">{l s='All groups'}</option>
{foreach from=$groups item=group}
 <option value="{$group.id_group}">{$group.name}</option>
{/foreach}
  </select>
 </div>
 <label>{l s='Customer:'}</label>
 <div class="margin-form">
  <input type="hidden" name="spm_id_customer" id="spm_id_customer" value="0" />
  <input type="text" name="customer_m" value="{l s='All customers'}" id="customer_m" autocomplete="off" />
  <img src="../img/admin/field-loader.gif" id="customerLoader" alt="{l s='Loading...'}" style="display: none;" />
  <div id="customers_m"></div>
 </div>
 {if $combinations|@count != 0}
  <label>{l s='Combination:'}</label>
  <div class="margin-form">
<select id="spm_id_product_attribute" name="spm_id_product_attribute">
 <option value="0">{l s='Apply to all combinations'}</option>
 {foreach from=$combinations item='combination'}
  <option value="{$combination.id_product_attribute}">{$combination.attributes}</option>
 {/foreach}
</select>
  </div>
 {/if}
 <label>{l s='Available from:'}</label>
 <div class="margin-form">
  <input class="datepicker" type="text" name="spm_from" value="" style="text-align: center" id="spm_from" /><span style="font-weight:bold; color:#000000; font-size:12px"> {l s='to'}</span>
  <input class="datepicker" type="text" name="spm_to" value="" style="text-align: center" id="spm_to" />
 </div>
 <label>{l s='Starting at'}</label>
 <div class="margin-form">
  <input type="text" name="spm_from_quantity" value="1" size="3" /> <span style="font-weight:bold; color:#000000; font-size:12px">{l s='unit'}</span>
 </div>
 <script type="text/javascript">
  $(document).ready(function(){
product_prices['0'] = $('#spm_current_ht_price').html();

$('#spm_id_product_attribute').change(function() {
 $('#spm_current_ht_price').html(product_prices[$('#spm_id_product_attribute option:selected').val()]);
});
$('#leavem_bprice').click(function() {
 if (this.checked)
  $('#spm_price').attr('disabled', 'disabled');
 else
  $('#spm_price').removeAttr('disabled');
});
  });
 </script>
 <label>{l s='Product price'}
  {if $country_display_tax_label}
{l s='(tax excl.):'}
  {/if}
 </label>
 <div class="margin-form">
  <span id="spm_currency_sign_pre_1" style="font-weight:bold; color:#000000; font-size:12px">
{$currency->prefix}
  </span>
  <input type="text" disabled="disabled" name="spm_price" id="spm_price" value="{$product->price|string_format:'%.2f'}" size="11" />
  <span id="spm_currency_sign_post_1" style="font-weight:bold; color:#000000; font-size:12px">
{$currency->suffix}
  </span>
 </div>
 <label>
  {l s='Leave base price:'}
 </label>
 <div class="margin-form">
  <input id="leavem_bprice" type="checkbox" value="1" checked="checked" name="leavem_bprice" />
 </div>
 <label>{l s='Apply a discount of:'}</label>
 <div class="margin-form">
  <input type="text" name="spm_reduction" value="0.00" size="11" />
  <select name="spm_reduction_type">
<option selected="selected">---</option>
<option value="amount">{l s='Amount'}</option>
<option value="percentage">{l s='Percentage'}</option>
  </select>
  <p class="preference_description">{l s='The discount is applied after the tax'}</p>
 </div>
</div>

 


 

Modify : /js/admin-product.js - "product_tabs['Prices'] = new function(){" as below :

 

product_tabs['Prices'] = new function(){
var self = this;
// Bind to show/hide new specific price form
this.toggleSpecificPrice = function (){
 $('#show_specific_price').click(function()
 {
  $('#add_specific_price').slideToggle();
  $('#edit_specific_price').hide();
  $('#add_specific_price').append('<input type="hidden" name="submitPriceAddition"/>');
  $('#hide_specific_price').show();
  $('#show_specific_price').hide();
  return false;
 });
 $('#hide_specific_price').click(function()
 {
  $('#add_specific_price').slideToggle();
  $('#edit_specific_price').hide();

  $('#add_specific_price').find('input[name=submitPriceAddition]').remove();
  $('#edit_specific_price').find('input[name=submitPriceEdition]').remove();
  $('#edit_specific_price').find('input[name=spm_id_specific_price]').remove();

  $('#hide_specific_price').hide();
  $('#show_specific_price').show();
  return false;
 });

 $('#hide_edit_specific_price').click(function()
 {
  $('#add_specific_price').hide();
  $('#edit_specific_price').hide();

  $('#add_specific_price').find('input[name=submitPriceAddition]').remove();
  $('#edit_specific_price').find('input[name=submitPriceEdition]').remove();
  $('#edit_specific_price').find('input[name=spm_id_specific_price]').remove();

  $('#hide_edit_specific_price').hide();
  $('#hide_specific_price').hide();
  $('#show_specific_price').show();
  return false;
 });
};
/**
 * Ajax call to delete a specific price
 *
 * @param ids
 * @param token
 * @param parent
 */
this.deleteSpecificPrice = function (url, parent){
 $.ajax({
  url: url,
  data: {
ajax: true
  },
  context: document.body,
  dataType: 'json',
  context: this,
  async: false,
  success: function(data) {
if (data !== null)
{
 if (data.status == 'ok')
 {
  showSuccessMessage(data.message);
  parent.remove();
 }
 else
  showErrorMessage(data.message);
}
  }
 });
};
// Bind to delete specific price link
this.bindDelete = function(){
 $('#specific_prices_list').delegate('a[name="delete_link"]', 'click', function(e){
  e.preventDefault();
  self.deleteSpecificPrice(this.href, $(this).parents('tr'));
 })
};

this.loadInformations = function(select_id, action)
{
 id_shop = $('#sp_id_shop').val();
 $.ajax({
  url: product_url + '&action='+action+'&ajax=true&id_shop='+id_shop,
  success: function(data) {
$(select_id + ' option').not(':first').remove();
$(select_id).append(data);
  }
 });
}

// Bind to edit specific price link
this.bindEdit = function(){
 $('#specific_prices_list').delegate('a[name="edit_link"]', 'click', function(e){
  e.preventDefault();
  self.editSpecificPrice(this.href, $(this).parents('tr'));
 })
};
this.editSpecificPrice = function(url, parent) {
 $.ajax({
  url: url,
  data: {
ajax: true
  },
  context: document.body,
  dataType: 'json',
  context: this,
  async: false,
  success: function(data) {
if (data !== null)
{
 if (data.status == 'ok')
 {
  $('#add_specific_price').hide();
  $('#hide_specific_price').hide();
  $('#show_specific_price').hide();

  $('#edit_specific_price').show();
  $('#hide_edit_specific_price').show();

  $('#add_specific_price').find('input[name=submitPriceAddition]').remove();
  $('#edit_specific_price').find('input[name=submitPriceEdition]').remove();
  $('#edit_specific_price').find('input[name=spm_id_specific_price]').remove();

  $('#edit_specific_price').append('<input type="hidden" name="submitPriceEdition"/>');
  $('#edit_specific_price').append('<input type="hidden" name="spm_id_specific_price" id="spm_id_specific_price"/>');

  $('#spm_id_specific_price').val(data.message[0].id);

  $('#spm_id_shop').val(data.message[0].id_shop);
  $('#spm_currency_1').val(data.message[0].id_currency);
  $('#spm_id_country').val(data.message[0].id_country);
  $('#spm_id_group').val(data.message[0].id_group);
  $('#spm_id_customer').val(data.message[0].id_customer);
  $('#spm_id_product_attribute').val(data.message[0].id_product_attribute);
  $('#spm_from').val(data.message[0].from);
  $('#spm_to').val(data.message[0].to);
  $('#spm_from_quantity').val(data.message[0].from_quantity);
  $('#spm_price').val(data.message[0].price);
  if (parseFloat(data.message[0].price) > 0) {
   $('#leavem_bprice').attr('checked', false);
   $('#spm_price').removeAttr('disabled');
  } else {
   $('#leavem_bprice').attr('checked', true);
   $('#spm_price').attr('disabled', 'disabled');
  }

  $('#spm_reduction').val(data.message[0].reduction);
  if (data.message[0].reduction_type == '')
   $('#spm_reduction_type').val('amount');
  else
   $('#spm_reduction_type').val(data.message[0].reduction_type);
 }
 else
  showErrorMessage(data.message);
}
  }
 });
};
this.onReady = function(){
 self.toggleSpecificPrice();
 self.deleteSpecificPrice();
 self.bindDelete();

 self.bindEdit();
 $('#sp_id_shop').change(function() {
  self.loadInformations('#sp_id_group','getGroupsOptions');
  self.loadInformations('#spm_currency_0', 'getCurrenciesOptions');
  self.loadInformations('#sp_id_country', 'getCountriesOptions');
 });
 $('#spm_id_shop').change(function() {
  self.loadInformations('#spm_id_group','getGroupsOptions');
  self.loadInformations('#spm_currency_1', 'getCurrenciesOptions');
  self.loadInformations('#spm_id_country', 'getCountriesOptions');
 });

 if (display_multishop_checkboxes)
  ProductMultishop.checkAllPrices();
};
}

 

And that's work ;-)

 

Cheers !

 

Serge Berney

Kin SA - www.kinsa.ch

Edited by Serge Berney :: Kin SA (see edit history)
Link to comment
Share on other sites

Oops, you're right, I miss to include a part of "AdminProductsController.php" override :

 

Add this on override to add the "edit" button :

public function processUpdate()
   {
       $this->checkProduct();

       if (!empty($this->errors))
       {
           $this->display = 'edit';
           return false;
       }

       $id = (int)Tools::getValue('id_'.$this->table);
       /* Update an existing product */
       if (isset($id) && !empty($id))
       {
           $object = new $this->className((int)$id);
           $this->object = $object;

           if (Validate::isLoadedObject($object))
           {
               $this->_removeTaxFromEcotax();
               $this->copyFromPost($object, $this->table);
               $object->indexed = 0;

               if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP)
                   $object->setFieldsToUpdate((array)Tools::getValue('multishop_check'));

               if ($object->update())
               {
                   if (in_array($this->context->shop->getContext(), array(Shop::CONTEXT_SHOP, Shop::CONTEXT_ALL)))
                   {
                       if ($this->isTabSubmitted('Shipping'))
                           $this->addCarriers();
                       if ($this->isTabSubmitted('Associations'))
                           $this->updateAccessories($object);
                       if ($this->isTabSubmitted('Suppliers'))
                           $this->processSuppliers();
                       if ($this->isTabSubmitted('Features'))
                           $this->processFeatures();
                       if ($this->isTabSubmitted('Combinations'))
                           $this->processProductAttribute();
                       if ($this->isTabSubmitted('Prices'))
                       {
                           $this->processPriceAddition();
                      	 $this->processPricesModification();

                           $this->processSpecificPricePriorities();
                           $this->object->id_tax_rules_group = (int)Tools::getValue('id_tax_rules_group');
                       }
                       if ($this->isTabSubmitted('Customization'))
                           $this->processCustomizationConfiguration();
                       if ($this->isTabSubmitted('Attachments'))
                           $this->processAttachments();

                       $this->updatePackItems($object);
                       $this->updateDownloadProduct($object, 1);
                       $this->updateTags(Language::getLanguages(false), $object);

                       if ($this->isProductFieldUpdated('category_box') && !$object->updateCategories(Tools::getValue('categoryBox'), true))
                           $this->errors[] = Tools::displayError('An error occurred while linking object.').' <b>'.$this->table.'</b> '.Tools::displayError('To categories');
                   }

                   if ($this->isTabSubmitted('Warehouses'))
                       $this->processWarehouses();
                   if (empty($this->errors))
                   {
                       Hook::exec('actionProductUpdate', array('product' => $object));

                       if (in_array($object->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION'))
                           Search::indexation(false, $object->id);

                       // Save and preview
                       if (Tools::isSubmit('submitAddProductAndPreview'))
                       {
                           $preview_url = $this->context->link->getProductLink(
                               $this->getFieldValue($object, 'id'),
                               $this->getFieldValue($object, 'link_rewrite', $this->context->language->id),
                               Category::getLinkRewrite($this->getFieldValue($object, 'id_category_default'), $this->context->language->id),
                               null,
                               null,
                               Context::getContext()->shop->id,
                               0,
                               (bool)Configuration::get('PS_REWRITING_SETTINGS')
                           );

                           if (!$object->active)
                           {
                               $admin_dir = dirname($_SERVER['PHP_SELF']);
                               $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
                               if (strpos($preview_url, '?') === false)
                                   $preview_url .= '?';
                               else
                                   $preview_url .= '&';
                               $preview_url .= 'adtoken='.$this->token.'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id;
                           }
                           $this->redirect_after = $preview_url;
                       }
                       else
                       {
                           // Save and stay on same form
                           if ($this->display == 'edit')
                           {
                               $this->confirmations[] = $this->l('Update successful');
                               $this->redirect_after = self::$currentIndex.'&id_product='.(int)$this->object->id
                                   .(Tools::getIsset('id_category') ? '&id_category='.(int)Tools::getValue('id_category') : '')
                                   .'&updateproduct&conf=4&key_tab='.Tools::safeOutput(Tools::getValue('key_tab')).'&token='.$this->token;
                           }
                           else
                               // Default behavior (save and back)
                               $this->redirect_after = self::$currentIndex.(Tools::getIsset('id_category') ? '&id_category='.(int)Tools::getValue('id_category') : '').'&conf=4&token='.$this->token;
                       }
                   }
                   // if errors : stay on edit page
                   else
                       $this->display = 'edit';
               }
               else
                   $this->errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b> ('.Db::getInstance()->getMsgError().')';
           }
           else
               $this->errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b> ('.Tools::displayError('Cannot load object').')';
           return $object;
       }
   }

protected function _displaySpecificPriceModificationForm($defaultCurrency, $shops, $currencies, $countries, $groups)
{
	$content = '';
	if (!($obj = $this->loadObject()))
		return;
	$specific_prices = SpecificPrice::getByProductId((int)$obj->id);
	$specific_price_priorities = SpecificPrice::getPriority((int)$obj->id);

	$tax_rate = $obj->getTaxesRate(Address::initialize());

	$tmp = array();
	foreach ($shops as $shop)
		$tmp[$shop['id_shop']] = $shop;
	$shops = $tmp;
	$tmp = array();
	foreach ($currencies as $currency)
		$tmp[$currency['id_currency']] = $currency;
	$currencies = $tmp;

	$tmp = array();
	foreach ($countries as $country)
		$tmp[$country['id_country']] = $country;
	$countries = $tmp;

	$tmp = array();
	foreach ($groups as $group)
		$tmp[$group['id_group']] = $group;
	$groups = $tmp;

	if (!is_array($specific_prices) || !count($specific_prices))
		$content .= '
			<tr>
				<td colspan="13">'.$this->l('No specific prices').'</td>
			</tr>';
	else
	{
		$i = 0;
		foreach ($specific_prices as $specific_price)
		{
			$current_specific_currency = $currencies[($specific_price['id_currency'] ? $specific_price['id_currency'] : $defaultCurrency->id)];
			if ($specific_price['reduction_type'] == 'percentage')
				$impact = '- '.($specific_price['reduction'] * 100).' %';
			elseif ($specific_price['reduction'] > 0)
				$impact = '- '.Tools::displayPrice(Tools::ps_round($specific_price['reduction'], 2), $current_specific_currency);
			else
				$impact = '--';

			if ($specific_price['from'] == '0000-00-00 00:00:00' && $specific_price['to'] == '0000-00-00 00:00:00')
				$period = $this->l('Unlimited');
			else
				$period = $this->l('From').' '.($specific_price['from'] != '0000-00-00 00:00:00' ? $specific_price['from'] : '0000-00-00 00:00:00').'<br />'.$this->l('To').' '.($specific_price['to'] != '0000-00-00 00:00:00' ? $specific_price['to'] : '0000-00-00 00:00:00');
			if ($specific_price['id_product_attribute'])
			{
				$combination = new Combination((int)$specific_price['id_product_attribute']);
				$attributes = $combination->getAttributesName((int)$this->context->language->id);
				$attributes_name = '';
				foreach ($attributes as $attribute)
					$attributes_name .= $attribute['name'].' - ';
				$attributes_name = rtrim($attributes_name, ' - ');
			}
			else
				$attributes_name = $this->l('All combinations');

			$rule = new SpecificPriceRule((int)$specific_price['id_specific_price_rule']);
			$rule_name = ($rule->id ? $rule->name : '--');

			if ($specific_price['id_customer'])
			{
				$customer = new Customer((int)$specific_price['id_customer']);
				if (Validate::isLoadedObject($customer))
					$customer_full_name = $customer->firstname.' '.$customer->lastname;
				unset($customer);
			}

			if (!$specific_price['id_shop'] || in_array($specific_price['id_shop'], Shop::getContextListShopID()))
			{
				$content .= '
				<tr '.($i % 2 ? 'class="alt_row"' : '').'>
					<td class="cell border">'.$rule_name.'</td>
					<td class="cell border">'.$attributes_name.'</td>';

				$can_delete_specific_prices = true;
				if (Shop::isFeatureActive())
				{
					$id_shop_sp = $specific_price['id_shop'];
					$can_delete_specific_prices = (count($this->context->employee->getAssociatedShops()) > 1 && !$id_shop_sp) || $id_shop_sp;
					$content .= '
					<td class="cell border">'.($id_shop_sp ? $shops[$id_shop_sp]['name'] : $this->l('All shops')).'</td>';
				}
				$price = Tools::ps_round($specific_price['price'], 2);
				$fixed_price = ($price == Tools::ps_round($obj->price, 2) || $specific_price['price'] == -1) ? '--' : Tools::displayPrice($price);
				$content .= '
					<td class="cell border">'.($specific_price['id_currency'] ? $currencies[$specific_price['id_currency']]['name'] : $this->l('All currencies')).'</td>
					<td class="cell border">'.($specific_price['id_country'] ? $countries[$specific_price['id_country']]['name'] : $this->l('All countries')).'</td>
					<td class="cell border">'.($specific_price['id_group'] ? $groups[$specific_price['id_group']]['name'] : $this->l('All groups')).'</td>
					<td class="cell border" title="'.$this->l('ID:').' '.$specific_price['id_customer'].'">'.(isset($customer_full_name) ? $customer_full_name : $this->l('All customers')).'</td>
					<td class="cell border">'.$fixed_price.'</td>
					<td class="cell border">'.$impact.'</td>
					<td class="cell border">'.$period.'</td>
					<td class="cell border">'.$specific_price['from_quantity'].'</th>
					<td class="cell border">'.
						((!$rule->id && $can_delete_specific_prices) ? '<a name="delete_link" href="'.self::$currentIndex.'&id_product='.(int)Tools::getValue('id_product').'&action=deleteSpecificPrice&id_specific_price='.(int)($specific_price['id_specific_price']).'&token='.Tools::getValue('token').'"><img src="../img/admin/delete.gif" alt="'.$this->l('Delete').'" /></a>': '').
				   	 ((!$rule->id) ? '<a name="edit_link" href="'.self::$currentIndex.'&id_product='.(int)Tools::getValue('id_product').'&action=editSpecificPrice&id_specific_price='.(int)($specific_price['id_specific_price']).'&token='.Tools::getValue('token').'"><img src="../img/admin/edit.gif" alt="'.$this->l('Edit').'" /></a>': '').
					'</td>
				</tr>';
				$i++;
				unset($customer_full_name);
			}
		}
	}
	$content .= '
		</tbody>
	</table>';

	$content .= '
	<script type="text/javascript">
		var currencies = new Array();
		currencies[0] = new Array();
		currencies[0]["sign"] = "'.$defaultCurrency->sign.'";
		currencies[0]["format"] = '.$defaultCurrency->format.';
		';
		foreach ($currencies as $currency)
		{
			$content .= '
			currencies['.$currency['id_currency'].'] = new Array();
			currencies['.$currency['id_currency'].']["sign"] = "'.$currency['sign'].'";
			currencies['.$currency['id_currency'].']["format"] = '.$currency['format'].';
			';
		}
		$content .= '
	</script>
	';

	// Not use id_customer
	if ($specific_price_priorities[0] == 'id_customer')
		unset($specific_price_priorities[0]);
	// Reindex array starting from 0
	$specific_price_priorities = array_values($specific_price_priorities);

	$content .= '
	<div class="separation"></div>
	<h4>'.$this->l('Priority management').'</h4>
	<div class="hint" style="display:block;min-height:0;">
			'.$this->l('Sometimes one customer can fit into multiple specific price rules. Priorities allow you to define which rule applies to the customer.').'
	</div
<br /><br />
	<label>'.$this->l('Priorities:').'</label>
	<div class="margin-form">
		<select name="specificPricePriority[]">
			<option value="id_shop"'.($specific_price_priorities[0] == 'id_shop' ? ' selected="selected"' : '').'>'.$this->l('Shop').'</option>
			<option value="id_currency"'.($specific_price_priorities[0] == 'id_currency' ? ' selected="selected"' : '').'>'.$this->l('Currency').'</option>
			<option value="id_country"'.($specific_price_priorities[0] == 'id_country' ? ' selected="selected"' : '').'>'.$this->l('Country').'</option>
			<option value="id_group"'.($specific_price_priorities[0] == 'id_group' ? ' selected="selected"' : '').'>'.$this->l('Group').'</option>
		</select>
		>
		<select name="specificPricePriority[]">
			<option value="id_shop"'.($specific_price_priorities[1] == 'id_shop' ? ' selected="selected"' : '').'>'.$this->l('Shop').'</option>
			<option value="id_currency"'.($specific_price_priorities[1] == 'id_currency' ? ' selected="selected"' : '').'>'.$this->l('Currency').'</option>
			<option value="id_country"'.($specific_price_priorities[1] == 'id_country' ? ' selected="selected"' : '').'>'.$this->l('Country').'</option>
			<option value="id_group"'.($specific_price_priorities[1] == 'id_group' ? ' selected="selected"' : '').'>'.$this->l('Group').'</option>
		</select>
		>
		<select name="specificPricePriority[]">
			<option value="id_shop"'.($specific_price_priorities[2] == 'id_shop' ? ' selected="selected"' : '').'>'.$this->l('Shop').'</option>
			<option value="id_currency"'.($specific_price_priorities[2] == 'id_currency' ? ' selected="selected"' : '').'>'.$this->l('Currency').'</option>
			<option value="id_country"'.($specific_price_priorities[2] == 'id_country' ? ' selected="selected"' : '').'>'.$this->l('Country').'</option>
			<option value="id_group"'.($specific_price_priorities[2] == 'id_group' ? ' selected="selected"' : '').'>'.$this->l('Group').'</option>
		</select>
		>
		<select name="specificPricePriority[]">
			<option value="id_shop"'.($specific_price_priorities[3] == 'id_shop' ? ' selected="selected"' : '').'>'.$this->l('Shop').'</option>
			<option value="id_currency"'.($specific_price_priorities[3] == 'id_currency' ? ' selected="selected"' : '').'>'.$this->l('Currency').'</option>
			<option value="id_country"'.($specific_price_priorities[3] == 'id_country' ? ' selected="selected"' : '').'>'.$this->l('Country').'</option>
			<option value="id_group"'.($specific_price_priorities[3] == 'id_group' ? ' selected="selected"' : '').'>'.$this->l('Group').'</option>
		</select>
	</div>

	<div class="margin-form">
		<input type="checkbox" name="specificPricePriorityToAll" id="specificPricePriorityToAll" /> <label class="t" for="specificPricePriorityToAll">'.$this->l('Apply to all products').'</label>
	</div>
	';
	return $content;
}

 

...

 

Serge Berney

Kin SA - www.kinsa.ch

Edited by Serge Berney :: Kin SA (see edit history)
Link to comment
Share on other sites

  • 4 weeks later...

Hello,

Thank you for the change that is sorely lacking on prestashop.

I have the same problem as Supremacy2k, it cancels the reduction and change me prices in negative, eg the price excluding tax is -1.000000.

Did you find a solution to the problem?

Best regard,

Pdriss

Link to comment
Share on other sites

Hello,

I noticed that the function: public function processPriceModification already existed in the file controllers/admin/AdminProductsController.php

can not I use this?

Home because the changes do not work, I use version 1.5.3.1 of PrestaShop.

Thank you for your help

Link to comment
Share on other sites

  • 3 weeks later...

Hello,

Thank you for the change that is sorely lacking on prestashop.

I have the same problem as Supremacy2k, it cancels the reduction and change me prices in negative, eg the price excluding tax is -1.000000.

Did you find a solution to the problem?

Best regard,

Pdriss

Same thing here...

after clicking edit, the reduction disapears, and price is set to -1.00000.

Link to comment
Share on other sites

  • 6 months later...

Hi guys, anyone help please....

 

I need to create a {if} function to hide specific payment modules when the client chooses a specific currency.

I use PS 1.3.6 (will not upgrade, works beautifully).

 

The thing goes like this:

if the client clicks on Currency X (currency id 7), I have to hide all payment modules except one.

 

Enabling/disabling the currency association with a specific module in the back office does not do the trick, meaning that all active modules are shown even if they are not associated with that particular currency id 7.

As such, a work around would be to individually hide any other payment module when that currency is selected and to show them if other currency than id 7 is used.

 

I tried this - just to test it, with the paypal module, in paypal.tpl:

 

{if $id_currency != 7}

.....show the paypal module....

{else}

... show a text ...

{/if}

 

Unfortunately the module is still shown.

 

Any suggestions appreciated!

Link to comment
Share on other sites

  • 2 months later...

personally there is little reason to put effort into more funciton at that level.

 

why?

 

because you need to edit every product to add/change/delete specific price.

 

The only real alternative IMHO is to buy a mass specific price module from addon's or a 3rd party developer.  Then you can use the full power of product specific prices...it's perfect for prices by country...

 

I bought one for my own shop...worth every penny.

Link to comment
Share on other sites

  • 1 month later...

Hi El Patron,

 

Could you let me know which mass editor are you using? I'm looking around but haven't made up my mind on which to get. Thanks :)

 

I use this on a 1.4 shop

 

Mass discounter v1.1 by ébewè - ebewe.net

Mass edit your promotions, by product or by category.

Link to comment
Share on other sites

  • 2 years later...

I have tried to get a solution to my issue from the general forum without any response so any help will be awesome!

Issue: Since updating to 1.6.1.6 the "Specific Prices" section of the "Price' area withing the product setup pages in the back-office are all empty.

Several of my products have "Specific Prices" that are active and work fine. However, when I go to edit, delete or add to one (or create a new one on a new product, for that matter) the page shows the message "No Specific Prices".

It gives me the option to create new "Specific Prices", but they never show up in that area, so they cannot be edited or deleted.

I have cleared and disabled and cleared again all cache options to no avail. This is making it imposible to change prices.

Thanks for any help!

Link to comment
Share on other sites

  • 2 months later...
×
×
  • Create New...