[Prestashop] How to fix edit product and delete product in back office order

Test should work for any 1.6.x.x, but only tested on 1.6.0.9, 1.6.0.11, and 1.6.1.4

There is a problem with the token. orders.js is the new file and orders.js.bak is the original js file. You will see the token is pulled from the url/href.

[email protected] [/home/bozzolo/www]# diff js/admin/orders.js js/admin/orders.js.bak
595c595
< 				token: window.location.href.split('token=')[1].split("&")[0],
---
> 				token: token,
685c685
< 			query = 'ajax=1&token='+window.location.href.split('token=')[1].split("&")[0]+'&action=editProductOnOrder&id_order='+id_order+'&';
---
> 			query = 'ajax=1&token='+token+'&action=editProductOnOrder&id_order='+id_order+'&';
762c762
< 		var query = 'ajax=1&action=deleteProductLine&token='+window.location.href.split('token=')[1].split("&")[0]+'&id_order_detail='+id_order_detail+'&id_order='+id_order;
---
> 		var query = 'ajax=1&action=deleteProductLine&token='+token+'&id_order_detail='+id_order_detail+'&id_order='+id_order;

 

Fix for this: Can’t edit/add ordered products in an order page

How to guide to get google adwords to work with your prestashop

After googling I couldn’t find any guide to get this to work. I had to piece together bunch of posts and spent a whole night of trial and error came up with this.

In order-confirmation.tpl add to the bottom and fill out your variables from your google adwords

<!-- Google Code for Purchase Conversion Page -->
<script type="text/javascript">
{literal} /* <![CDATA[ */ {/literal}
var google_conversion_id = ENTER_YOUR_ID_HERE;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "ENTER_YOUR_LABEL_HERE";
var google_conversion_value = {$total_pay};
var google_conversion_currency = "{$currencyiso}";
var google_remarketing_only = false;
{literal}/* ]]>*/ {/literal}
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/ENTER_YOUR_ID_HERE/?value={$total_pay}&amp;currency_code={$currencyiso}&amp;label=ENTER_YOUR_LABEL_HERE&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

in OrderConfirmationController.php add below in initContent function

        public function initContent()
        {
                parent::initContent();

                $this->context->smarty->assign(array(
                        'is_guest' => $this->context->customer->is_guest,
                        'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(),
                        'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn()
                ));


$order = new Order($this->id_order);
$currency = new Currency($order->id_currency);
$this->context->smarty->assign(array(
'total_pay' => $order->getOrdersTotalPaid(),
'currencyiso' => $currency->iso_code
));
                if ($this->context->customer->is_guest)
                {

to test if this is working I used the google tag assistant chrome extension and made a bunch of orders using bankwire payment method.

Good luck….

 

 

https://www.prestashop.com/forums/topic/444305-how-to-guide-to-get-google-adwords-to-work-with-your-prestashop/

Prestashop – Create Unique Reference ID with Product Combinations Generator

I use the prestashop amazon module and Amazon requires a unique reference number per combination. To save time modifying each reference I modified the combinations generator controller. If you have tons of attributes this will save you tons of time.

I’m pretty noob at this kind of stuff but it works. If you know a better way to do this let me know.

Thanks, zeki893

Here we go:

open AdminAttributeGeneratorController.php

Look for function addAttribute

You’ll see

foreach ($attributes as $attribute)
{
$price += (float)preg_replace('/[^0-9.-]/', '', str_replace(',', '.', Tools::getValue('price_impact_'.(int)$attribute)));
$weight += (float)preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('weight_impact_'.(int)$attribute)));
}

I modified it into

foreach ($attributes as $attribute)
{
$price += (float)preg_replace('/[^0-9.-]/', '', str_replace(',', '.', Tools::getValue('price_impact_'.(int)$attribute)));
$weight += (float)preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('weight_impact_'.(int)$attribute)));

//get the attributes name
$sqltest = 'SELECT * FROM `attribute_lang` WHERE `id_attribute` = '. $attribute .' LIMIT 0 , 1';
if ($resultstest = Db::getInstance()->ExecuteS($sqltest))
foreach ($resultstest as $rowtest)
$id_attribute_name = $rowtest[name];

//get the attributes group id to see if its color or size
$sqltest2 = 'SELECT * FROM `attribute` WHERE `id_attribute` = '. $attribute .' LIMIT 0 , 1';
if ($resultstest2 = Db::getInstance()->ExecuteS($sqltest2))
foreach ($resultstest2 as $rowtest2)
$id_attribute_colorsize = $rowtest2[id_attribute_group];

//this will determine if the attribute is a color or size
//11 is the color group id in my mysql database
if ($id_attribute_colorsize== 11) {
$id_attribute_color=$id_attribute_name;
} 
//12 is the size group id in my mysql database
elseif ($id_attribute_colorsize == 12) {
$id_attribute_size=$id_attribute_name;
}
}

You will need to modify

$id_attribute_colorsize== 11 and $id_attribute_colorsize == 12

I checked mysql attribute_group table to find the attribute group ID of color and size.

right below it you’ll find

if ($this->product->id)
{
return array(
'id_product' => (int)$this->product->id,
'price' => (float)$price,
'weight' => (float)$weight,
'ecotax' => 0,
'quantity' => (int)Tools::getValue('quantity'),
'reference' => pSQL($_POST['reference']),
'default_on' => 0,
'available_date' => '0000-00-00'
);
}

modify

‘reference’ => pSQL($_POST[‘reference’]),

to

‘reference’ => pSQL($_POST[‘reference’]).$id_attribute_color.’_’.$id_attribute_size,

You can re-order color or size anyway you’d like.

Your results will look like this.
products combinations generator
full modified function:

protected function addAttribute($attributes, $price = 0, $weight = 0)
  {
    foreach ($attributes as $attribute)
    {
      $price += (float)preg_replace('/[^0-9.-]/', '', str_replace(',', '.', Tools::getValue('price_impact_'.(int)$attribute)));
      $weight += (float)preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('weight_impact_'.(int)$attribute)));
      //get attribute name
      $sqltest = 'SELECT * FROM  `attribute_lang` WHERE  `id_attribute` = '. $attribute .' LIMIT 0 , 1';
      if ($resultstest = Db::getInstance()->ExecuteS($sqltest))
    			foreach ($resultstest as $rowtest)
        			$id_attribute_name = $rowtest[name];
        		//echo $id_attribute_name;
      //get attribute color or size
      $sqltest2 = 'SELECT * FROM  `attribute` WHERE  `id_attribute` = '. $attribute .' LIMIT 0 , 1';
      if ($resultstest2 = Db::getInstance()->ExecuteS($sqltest2))
    			foreach ($resultstest2 as $rowtest2)
        			$id_attribute_colorsize = $rowtest2[id_attribute_group];
        	if ($id_attribute_colorsize== 11) {
        		$id_attribute_color=$id_attribute_name;

        	} elseif ($id_attribute_colorsize == 12) {
        		$id_attribute_size=$id_attribute_name;
        	}
    }

    if ($this->product->id)
    {
      return array(
        'id_product' => (int)$this->product->id,
        'price' => (float)$price,
        'weight' => (float)$weight,
        'ecotax' => 0,
        'quantity' => (int)Tools::getValue('quantity'),
        'reference' => pSQL($_POST['reference']).$id_attribute_color.'_'.$id_attribute_size,
        'default_on' => 0,
        'available_date' => '0000-00-00'
      );
    }
    return array();
  }

This can also be done via overrides so you don’t modify the core file.