Gift Certificate Error After Return Request Submitted

Step 1: Create the Override File

Following the instructions and recommendations in the Patch Using Override Mode procedure, create a new directory and file: /Modules/extensions/ReturnAuthorization@1.0.0/JavaScript/ReturnAuthorization.Model.js. In the new ReturnAuthorization.Model.js file, find and replace the following line of code with the provided code sample.

setLines: function (return_authorization, lines, transaction_lines)
{
var line_count = return_authorization.getLineItemCount('item')
, add_line = true
, i = 1;
while (i <= line_count)
{
var line_item_value =
return_authorization.getLineItemValue('item', 'id', i);
add_line = this.findLine(line_item_value, lines);
if (add_line)
{
var transaction_line = _.findWhere(transaction_lines,
{ line: line_item_value });
if (transaction_line)
{
return_authorization.setLineItemValue('item',
'rate', i, transaction_line.rate);
}
return_authorization.setLineItemValue('item',
'quantity', i, add_line.quantity);
return_authorization.setLineItemValue('item',
'description', i, add_line.reason);
i++;
}
else
{
var item_type =
return_authorization.getLineItemValue('item', 'itemtype', i);
if (item_type == 'GiftCert') {
return_authorization.removeLineItem('item', i);
line_count--;
} else {
return_authorization.setLineItemValue('item',
'quantity', i, 0);
i++;
}
}
}
}

Step 2: Prepare the Developer Tools For Your Patch

When preparing the Developer Tools for your patch as described in the Patch Using Override Mode procedure, perform the following actions:

  1. Paste the following sample code into the new ns.package.json file that you create in the Modules directory: /Modules/extensions/ReturnAuthorizationExtension@1.0.0/ns.package.json
{
    "gulp": {
        "javascript": [
            "JavaScript/*.js"
        ]
 },
   "overrides": {
      "suitecommerce/ReturnAuthorization@X.Y.Z/JavaScript/ReturnAuthorization.Model.js" : "JavaScript/ReturnAuthorization.Model.js"
   }
}

Open the distro.json file in the root SCA development directory and then add your custom module to the modules object as described in the Patch Using Override Mode procedure. The following sample shows the value to add to the list of existing values that follow the “modules” key.

Step 3: Test and Deploy Your Patch

Leave a comment

Your email address will not be published. Required fields are marked *