Skip to content

Modify “Gift Wrapping for Order” Text in Order Email

I am trying to change the text that says “Gift Wrapping for Order” to “Gift Messaging” in the order confirmation email that is sent out.

enter image description here

I have figured out where the copy needs to be updated to actually, change it, but I’m struggling with getting my module to work so I can override the /vendor/magento/module-gift-wrapping/Helper/Data.php file properly.

Here is my module:

app/code/Vendor/ModuleName/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_ModuleName">
    </module>
</config>

app/code/Vendor/ModuleName/etc/di.xml

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="MagentoGiftWrappingHelperData" type="VendorModuleNameHelperData" />
</config>

app/code/Vendor/ModuleName/Helper/Data.php

<?php

namespace VendorModuleNameHelper;

class Data extends MagentoGiftWrappingHelperData
{   
/**
 * Return totals of data object
 *
 * @param  MagentoFrameworkDataObject $dataObject
 * @return array
 * @SuppressWarnings(PHPMD.CyclomaticComplexity)
 * @SuppressWarnings(PHPMD.NPathComplexity)
 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
 */
public function getTotals($dataObject)
{
    $totals = [];

    $displayWrappingBothPrices = false;
    $displayWrappingIncludeTaxPrice = false;
    $displayCardBothPrices = false;
    $displayCardIncludeTaxPrice = false;

    if ($dataObject instanceof MagentoSalesModelOrder ||
        $dataObject instanceof MagentoSalesModelOrderInvoice ||
        $dataObject instanceof MagentoSalesModelOrderCreditmemo
    ) {
        $displayWrappingBothPrices = $this->displaySalesWrappingBothPrices();
        $displayWrappingIncludeTaxPrice = $this->displaySalesWrappingIncludeTaxPrice();
        $displayCardBothPrices = $this->displaySalesCardBothPrices();
        $displayCardIncludeTaxPrice = $this->displaySalesCardIncludeTaxPrice();
    } elseif ($dataObject instanceof MagentoQuoteModelQuoteAddressTotal) {
        $displayWrappingBothPrices = $this->displayCartWrappingBothPrices();
        $displayWrappingIncludeTaxPrice = $this->displayCartWrappingIncludeTaxPrice();
        $displayCardBothPrices = $this->displayCartCardBothPrices();
        $displayCardIncludeTaxPrice = $this->displayCartCardIncludeTaxPrice();
    }

    /**
     * Gift Messaging totals
     */
    if ($displayWrappingBothPrices || $displayWrappingIncludeTaxPrice) {
        if ($displayWrappingBothPrices) {
            $this->_addTotalToTotals(
                $totals,
                'gw_order_excl',
                $dataObject->getGwPrice(),
                $dataObject->getGwBasePrice(),
                'Gift Messaging (Excl. Tax)'
            );
        }
        $this->_addTotalToTotals(
            $totals,
            'gw_order_incl',
            $dataObject->getGwPrice() + $dataObject->getGwTaxAmount(),
            $dataObject->getGwBasePrice() + $dataObject->getGwBaseTaxAmount(),
            'Gift Messaging (Incl. Tax)'
        );
    } else {
        $this->_addTotalToTotals(
            $totals,
            'gw_order',
            $dataObject->getGwPrice(),
            $dataObject->getGwBasePrice(),
            'Gift Messaging'
        );
    }

    /**
     * Gift wrapping for items totals
     */
    if ($displayWrappingBothPrices || $displayWrappingIncludeTaxPrice) {
        $this->_addTotalToTotals(
            $totals,
            'gw_items_incl',
            $dataObject->getGwItemsPrice() + $dataObject->getGwItemsTaxAmount(),
            $dataObject->getGwItemsBasePrice() + $dataObject->getGwItemsBaseTaxAmount(),
            'Gift Wrapping for Items (Incl. Tax)'
        );
        if ($displayWrappingBothPrices) {
            $this->_addTotalToTotals(
                $totals,
                'gw_items_excl',
                $dataObject->getGwItemsPrice(),
                $dataObject->getGwItemsBasePrice(),
                'Gift Wrapping for Items (Excl. Tax)'
            );
        }
    } else {
        $this->_addTotalToTotals(
            $totals,
            'gw_items',
            $dataObject->getGwItemsPrice(),
            $dataObject->getGwItemsBasePrice(),
            'Gift Wrapping for Items'
        );
    }

    /**
     * Printed card totals
     */
    if ($displayCardBothPrices || $displayCardIncludeTaxPrice) {
        $this->_addTotalToTotals(
            $totals,
            'gw_printed_card_incl',
            $dataObject->getGwCardPrice() + $dataObject->getGwCardTaxAmount(),
            $dataObject->getGwCardBasePrice() + $dataObject->getGwCardBaseTaxAmount(),
            'Printed Card (Incl. Tax)'
        );
        if ($displayCardBothPrices) {
            $this->_addTotalToTotals(
                $totals,
                'gw_printed_card_excl',
                $dataObject->getGwCardPrice(),
                $dataObject->getGwCardBasePrice(),
                'Printed Card (Excl. Tax)'
            );
        }
    } else {
        $this->_addTotalToTotals(
            $totals,
            'gw_printed_card',
            $dataObject->getGwCardPrice(),
            $dataObject->getGwCardBasePrice(),
            'Printed Card'
        );
    }

    return $totals;
}

}
?>

What am I missing?