Jump to content

[FIX] Order Refund/Delivery Slip BUG in PS v1.4.8.2? [EDITED FOR PS v1.5.4.1]


Recommended Posts

Hi,

 

Not sure if this has already been reported or fixed, and not entirely sure if this is a bug or was meant to be. But we did not like how the refund option was working after upgrading from v1.4.5.1 to v1.4.8.2

 

We liked the way it performed in the previous version MUCH better.

 

ISSUE:

Basically, we usually update the order status to "Preparation in progress" and then if there are any out of stock (back-order or discontinued) items then we would notify the customer. The customer will usually request an exchange item or a refund for the unavailable item(s). In the olde version, lets say if there were 5 items in the order and the customer wanted a refund for 1 of those items, we would check the checkbox and check the "generate a credit slip" button and press the "refund products" button. It would remove this item, which all works fine. However, when the product is refunded and a credit slip generated, then the refunded item should be removed from the new delivery slip. However, after the upgrade this was not the case. In the Admin Orders tab it showed that the item had been refunded from the list; however, all delivery slips showed the orginal list including the refunded item.

 

SOLUTION:

You have to edit /classes/Order.php file.

 

1) Search for hasBeenDelivered() (without quotes; around line 650)

 

Change this line:

return count($this->getHistory((int)($this->id_lang), false, false, OrderState::FLAG_DELIVERY));

 

TO

 

return sizeof($this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_DELIVERED')));

 

2) Search for "hasBeenPaid()" (without quotes)

 

Change this line:

return count($this->getHistory((int)($this->id_lang), false, false, OrderState::FLAG_LOGABLE));

 

TO

 

return sizeof($this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_PAYMENT')));

 

Save and upload.

 

This should fix this bug and when a product is refunded before it has been delivered (order status update) the new delivery slips will omit the refunded product, and the Credit Slip will continue to show what has been refunded to the customer.

 

HTH!

Edited by mytheory. (see edit history)
Link to comment
Share on other sites

  • 10 months later...

Hi,

 

Wanted to post an update for those having this same issue with the newest version of PS (v1.5.4.1). We just upgraded and noticed the same issue was still there (maybe its not a bug -- doesn't make sense to us).

 

Anyways, after a lot of searching, I couldn't find a solution and the solution above no longer works for PS v.1.5.x.

 

However, turns out the solution is actually quite simple... it's quick and dirty, but it works!

 

So to begin you need to edit /pdf/delivery-slip.tpl file. Scroll down to around line 108.

 

Basically look for this section of code:

 

{foreach $order_details as $product}
{cycle values='#FFF,#DDD' assign=bgcolor}
<tr style="line-height:6px;background-color:{$bgcolor};">

 <td style="text-align: left; width: 60%">{Manufacturer::getNameById($product.id_manufacturer)} - {$product.product_name}</td>
 <td style="text-align: left; width: 20%">
  {if empty($product.product_reference)}
   ---
  {else}
   {$product.product_reference}
  {/if}
 </td>
 <td style="text-align: center; width: 20%">{$product.product_quantity}</td>
</tr>
{/foreach}

 

And to it I just added an if-else statement to filter out refunded or returned products from the product list that is generated. So, change it to the following... you just add 2 lines of code to the above block... so notice the top IF statment and the closing IF block near the end.

 

{foreach $order_details as $product}
{if $product.product_quantity_refunded == 0 && $product.product_quantity_return == 0} <!--line added by mytheory. for delivery slip mod-->
{cycle values='#FFF,#DDD' assign=bgcolor}
<tr style="line-height:6px;background-color:{$bgcolor};">

 <td style="text-align: left; width: 60%">{Manufacturer::getNameById($product.id_manufacturer)} - {$product.product_name}</td>
 <td style="text-align: left; width: 20%">
  {if empty($product.product_reference)}
   ---
  {else}
   {$product.product_reference}
  {/if}
 </td>
 <td style="text-align: center; width: 20%">{$product.product_quantity}</td>
</tr>
{/if} <!--line added by mytheory. for delivery slip mod-->
{/foreach}

 

Well that's it! Try downloading a new delivery slip and it should take effect immediately as pdfs are generated on the spot.

 

I hope this helps someone out there who also doesn't understand why this is not enabled by default.

 

Thanks!

Edited by mytheory. (see edit history)
Link to comment
Share on other sites

Hi,

 

I noticed that there were some issues when the refunded item had a quantity more than 1. For example, lets assume the customer only ordered 1 product but ordered a quantity of 2. Now lets say that we had to issue a refund for 1 of those items, the mod from above would not show the product or the remaining quantity that still needs to be shipped. This is because it removes all items from the delivery slip that has already been refunded or returned regardless of quantity.

 

I modified the code to take into account the refunded quantity. The only difference is that even if the item is fully refunded it will still show the product name as a line item but with a ZERO quantity. Its a quick fix so it does not remove the item completely. This may be caveat for some, but for us it actually works better. Our shipping department can still take into account the refunded item and can make note of it a lot easier for purchasing.

 

HERE's the new block of code... same file and line from above.

 

   {foreach $order_details as $product}
   {cycle values='#FFF,#DDD' assign=bgcolor}
   <tr style="line-height:6px;background-color:{$bgcolor};">

 <td style="text-align: left; width: 60%">{Manufacturer::getNameById($product.id_manufacturer)} - {$product.product_name}</td>
 <td style="text-align: left; width: 20%">
  {if empty($product.product_reference)}
   ---
  {else}
   {$product.product_reference}
  {/if}
 </td>
 <td style="text-align: center; width: 20%">{if $product.product_quantity_refunded}{$product.product_quantity-$product.product_quantity_refunded}{elseif $product.product_quantity_return}{$product.product_quantity-$product.product_quantity_return}{else}{$product.product_quantity}{/if}</td>
   </tr>
   {/foreach}

 

Please note that I have completely removed the if-else statement from above. I have added another if-else statement to the quantity section.

 

HTH!

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...