X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   "Track Package" with Google for "Order Shipped" Email notification (https://forum.x-cart.com/showthread.php?t=76313)

CDWPChris 06-08-2018 11:43 AM

"Track Package" with Google for "Order Shipped" Email notification
 
I decided to make a change to the way the tracking information shows on the "Order Shipped" email notification. This is useful for companies that ship using UPS, FedEx, & USPS without using the modules. We typically offer "Standard Shipping" for a flat rate but we utilize all three shipping methods.

Step 1
Insert the following code at line 2123 of file
Quote:

/Classes/XLite/Model/Order.php

PHP Code:

/**
     * Get the link for the google tracking information
     *
     * @param string $trackingNumber Tracking number value
     *
     * @return string
     */
    
public function getGoogleTrackingURL($trackingNumber)
    {
        return 
$this->"https://www.google.com/search?q=".$trackingNumber;
    } 


Step 2

In your admin console, go to:

Quote:

Store Setup -> Email notifications -> Order Shipped

Click the "Edit via Webmaster Mode" button.

Scroll to the bottom of the page and click on the label "Tracking numbers:"



Open the editor and change the code in bold below:

Original Code:
Code:

{##
 # ____file_title____
 #
 # @ListChild (list="tracking.info", weight="10")
 #}

<p style="font-weight: bold;">{{ t('Tracking numbers') }}:</p>

{% for number in this.trackingNumbers %}
<div>
{% if this.order.getTrackingInformationURL(number.value) %}
{% if this.order.isTrackingInformationForm(number.value) %}
<form method="{{ this.order.getTrackingInformationMethod(number.value)|raw }}" action="{{ this.order.getTrackingInformationURL(number.value) }}" target="_blank" >
{% for name, value in this.order.getTrackingInformationParams(number.value) %}
<input type="hidden" name="{{ name }}" value="{{ value }}" />
{% endfor %}
<span>{{ number.value }} - </span>
<button type="submit">{{ t('Track package') }}</button>
</form>
{% else %}
<span>{{ number.value }} - </span>
<a href="{{ this.order.getTrackingInformationURL(number.value) }}" target="_blank">{{ t('Track package') }}</a>
{% endif %}
{% else %}
{{number.value}}
</a>
{% endif %}
</div>
{% endfor %}


New Code:
Code:

{##
 # ____file_title____
 #
 # @ListChild (list="tracking.info", weight="10")
 #}

<p style="font-weight: bold;">{{ t('Tracking numbers') }}:</p>

{% for number in this.trackingNumbers %}
<div>
{% if this.order.getTrackingInformationURL(number.value) %}
{% if this.order.isTrackingInformationForm(number.value) %}
<form method="{{ this.order.getTrackingInformationMethod(number.value)|raw }}" action="{{ this.order.getTrackingInformationURL(number.value) }}" target="_blank" >
{% for name, value in this.order.getTrackingInformationParams(number.value) %}
<input type="hidden" name="{{ name }}" value="{{ value }}" />
{% endfor %}
<span>{{ number.value }} - </span>
<button type="submit">{{ t('Track package') }}</button>
</form>
{% else %}
<span>{{ number.value }} - </span>
<a href="{{ this.order.getTrackingInformationURL(number.value) }}" target="_blank">{{ t('Track package') }}</a>
{% endif %}
{% else %}
<span>{{ number.value }} - </span>
<a href="{{ this.order.getGoogleTrackingURL(number.value) }}" target="_blank">{{ t('Track Package') }}</a>

{% endif %}
</div>
{% endfor %}


Make sure to click the "Save Changes" button!

Step 3

Re-deploy Store

Quote:

System Tools -> Cache Management



The track package button will open a new tab and navigate to a google search with the tracking number. Google will automatically detect the carrier based on the tracking number and offer a link to the carrier's tracking page.

Note: You will probably have to repeat step 1 after a core upgrade, unless XC decides to add this to the core in future updates.


All times are GMT -8. The time now is 06:58 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.