Post by xristos88 » Mon Apr 23, 2018 3:23 pm

Hello,
I want to ask where I can import xml code so that when a customer order a product to be automatically charged, depending on the country and the pounds of the order.
I contacted the TNT courier where they gave me the corresponding code.
1. Where should I enter the code?
2. How do you communicate with the purchase form so that the <delivery>, <product>, <currency>, ... and the rest fields are automatically taken.
The username and password I have received from the TNT courier.
My site http://www.komboloiart.gr
Thank you!!

Xml code from TNT:

Code: Select all

<?php

    $Xml = "<?xml version='1.0' encoding='UTF-8'?>
                <priceRequest xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
                    <appId>PC</appId>
                    <appVersion>3.0</appVersion>
                    <priceCheck>
                        <rateId>rate2</rateId>
                        <sender>
                            <country>GR</country>
                            <town>THESSALONIKI CENTER</town>
                            <postcode>546 29</postcode>
                        </sender>
                        <delivery>
                            <country>IT</country>
                            <town>Milano</town>
                            <postcode>20138</postcode>
                        </delivery>
                        <collectionDateTime>2017-10-31T20:12:00</collectionDateTime>
                        <product>
                            <id>15N</id>
                            <division>G</division>
                            <type>N</type>
                        </product>
                        <currency>EUR</currency>
                        <priceBreakDown>true</priceBreakDown>
                        <consignmentDetails>
                            <totalWeight>1.25</totalWeight>
                            <totalVolume>0.1</totalVolume>
                            <totalNumberOfPieces>1</totalNumberOfPieces>
                        </consignmentDetails>
						<pieceLine>
							<numberOfPieces>1</numberOfPieces>
							<pieceMeasurements>
								<length>1</length>
								<width>2</width>
								<height>3</height>
								<weight>1.25</weight>
							</pieceMeasurements>
							<pallet>1</pallet>
						</pieceLine>
                        
                    </priceCheck>
                </priceRequest>
";

    $username = "YOUR_USERNAME";
    $password = "YOUR_PASSWORD";
    $host = "https://express.tnt.com/expressconnect/pricing/getprice";

    curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);

    $process = curl_init($host);
    curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', $additionalHeaders));
    curl_setopt($process, CURLOPT_HEADER, 1);
    curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
    curl_setopt($process, CURLOPT_TIMEOUT, 30);
    curl_setopt($process, CURLOPT_POST, 1);
    curl_setopt($process, CURLOPT_POSTFIELDS, $Xml);
    curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
    $return = curl_exec($process);
    curl_close($process);


    if ( curl_errno($process) ) {
        $result = 'ERROR -> ' . curl_errno($process) . ': ' . curl_error($ch);
    } else {
        $returnCode = (int)curl_getinfo($process, CURLINFO_HTTP_CODE);
        switch($returnCode){
            case 200:
                break;
            default:
                $result = 'HTTP ERROR -> ' . $returnCode;
                break;
        }
    }

    echo $return;
    

Newbie

Posts

Joined
Mon Dec 04, 2017 7:53 pm

Post by georgeGB » Thu Jun 14, 2018 4:16 pm

xristos88 wrote:
Mon Apr 23, 2018 3:23 pm
Hello,
I want to ask where I can import xml code so that when a customer order a product to be automatically charged, depending on the country and the pounds of the order.
I contacted the TNT courier where they gave me the corresponding code.
1. Where should I enter the code?
2. How do you communicate with the purchase form so that the <delivery>, <product>, <currency>, ... and the rest fields are automatically taken.
The username and password I have received from the TNT courier.
My site http://www.komboloiart.gr
Thank you!!

Xml code from TNT (more):

Code: Select all

<?php

    $Xml = "<?xml version='1.0' encoding='UTF-8'?>
                <priceRequest xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
                    <appId>PC</appId>
                    <appVersion>3.0</appVersion>
                    <priceCheck>
                        <rateId>rate2</rateId>
                        <sender>
                            <country>GR</country>
                            <town>THESSALONIKI CENTER</town>
                            <postcode>546 29</postcode>
                        </sender>
                        <delivery>
                            <country>IT</country>
                            <town>Milano</town>
                            <postcode>20138</postcode>
                        </delivery>
                        <collectionDateTime>2017-10-31T20:12:00</collectionDateTime>
                        <product>
                            <id>15N</id>
                            <division>G</division>
                            <type>N</type>
                        </product>
                        <currency>EUR</currency>
                        <priceBreakDown>true</priceBreakDown>
                        <consignmentDetails>
                            <totalWeight>1.25</totalWeight>
                            <totalVolume>0.1</totalVolume>
                            <totalNumberOfPieces>1</totalNumberOfPieces>
                        </consignmentDetails>
						<pieceLine>
							<numberOfPieces>1</numberOfPieces>
							<pieceMeasurements>
								<length>1</length>
								<width>2</width>
								<height>3</height>
								<weight>1.25</weight>
							</pieceMeasurements>
							<pallet>1</pallet>
						</pieceLine>
                        
                    </priceCheck>
                </priceRequest>
";

    $username = "YOUR_USERNAME";
    $password = "YOUR_PASSWORD";
    $host = "https://express.tnt.com/expressconnect/pricing/getprice";

    curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);

    $process = curl_init($host);
    curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', $additionalHeaders));
    curl_setopt($process, CURLOPT_HEADER, 1);
    curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
    curl_setopt($process, CURLOPT_TIMEOUT, 30);
    curl_setopt($process, CURLOPT_POST, 1);
    curl_setopt($process, CURLOPT_POSTFIELDS, $Xml);
    curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
    $return = curl_exec($process);
    curl_close($process);


    if ( curl_errno($process) ) {
        $result = 'ERROR -> ' . curl_errno($process) . ': ' . curl_error($ch);
    } else {
        $returnCode = (int)curl_getinfo($process, CURLINFO_HTTP_CODE);
        switch($returnCode){
            case 200:
                break;
            default:
                $result = 'HTTP ERROR -> ' . $returnCode;
                break;
        }
    }

    echo $return;
    
Hello

As for the code, can't tell you. But here's the solution for the <currency> automation suggested here on OpenCart forum by the user (victorj). Perhaps, you should try setting the currencies for each country.

George
GB

User avatar
Newbie

Posts

Joined
Thu Jun 14, 2018 3:27 pm
Who is online

Users browsing this forum: No registered users and 29 guests