Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How To Add A New Carrier Rate Topic   * * * * * 2 votes

 
  • sunil0907
  • Member
  • Trial users
  • Join Date: 14-Sep 16
  • 47 posts

Posted 12 October 2016 - 08:52 AM #61

Hello,

 

Related to this topic,

 

How can I delete a carrier that is being shown in the carriers list while creating a shipment?

My marketplace is based in India and carriers like USPS, UPS, etc. will never be used in my case.

Please suggest.

 

Thanks,

Sunil



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19782 posts

Posted 12 October 2016 - 01:16 PM #62

How can I delete a carrier that is being shown in the carriers list while creating a shipment?

My marketplace is based in India and carriers like USPS, UPS, etc. will never be used in my case.

Please suggest.

 

You can clear the cscart_shipping_services table. Search unnecessary services by the value of the module column


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • MimiWatch
  • Member
  • Members
  • Join Date: 14-Jun 08
  • 137 posts

Posted 12 October 2016 - 01:17 PM #63

Hello,

 

Related to this topic,

 

How can I delete a carrier that is being shown in the carriers list while creating a shipment?

My marketplace is based in India and carriers like USPS, UPS, etc. will never be used in my case.

Please suggest.

 

Thanks,

Sunil

 

Change  fn.cart.php line 2536



 
  • gijoy
  • Advanced Member
  • Members
  • Join Date: 29-Feb 16
  • 60 posts

Posted 17 November 2016 - 09:42 AM #64

Yes ive edited it there as well, but where should i see the effect? When i check the shipments of an order, nothing changes. I attached a screenshot to show which block i mean.

 

I got it working in the email and for the client control panel, except in this block in the admin panel. Any suggestions which file i should edit for this?

p.s. eComlabs if you want to check, you got the temp ftp now :)

post-26448-0-80680400-1470838309_thumb.p



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19782 posts

Posted 17 November 2016 - 02:33 PM #65

gijoy, I have edited the design/backend/templates/views/orders/details.tpl file and added
 

{$shipment.tracking_url = $shipment.tracking_url|replace:"[country]":$order_info.s_country}
{$shipment.tracking_url = $shipment.tracking_url|replace:"[zipcode]":$order_info.s_zipcode}

before the following string of code:

<a href="{$shipment.tracking_url nofilter}" target="_blank" id="on_tracking_number_{$shipment_key}">{if $shipment.tracking_number}{$shipment.tracking_number}{else}&mdash;{/if}</a>

It solved the issue. Please take a look


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • gijoy
  • Advanced Member
  • Members
  • Join Date: 29-Feb 16
  • 60 posts

Posted 17 November 2016 - 10:29 PM #66

gijoy, I have edited the design/backend/templates/views/orders/details.tpl file and added
 

{$shipment.tracking_url = $shipment.tracking_url|replace:"[country]":$order_info.s_country}
{$shipment.tracking_url = $shipment.tracking_url|replace:"[zipcode]":$order_info.s_zipcode}

before the following string of code:

<a href="{$shipment.tracking_url nofilter}" target="_blank" id="on_tracking_number_{$shipment_key}">{if $shipment.tracking_number}{$shipment.tracking_number}{else}&mdash;{/if}</a>

It solved the issue. Please take a look

 

awesome, tyvm



 
  • gijoy
  • Advanced Member
  • Members
  • Join Date: 29-Feb 16
  • 60 posts

Posted 18 November 2016 - 10:19 AM #67

I couldn't get it to work on live, but for some reason "clear cache" wasn't enough. Apparently "rebuild cache automatically" is more thorough and it worked after I enabled that option for a few seconds. It's perfect now!



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11392 posts

Posted 18 November 2016 - 05:29 PM #68

I couldn't get it to work on live, but for some reason "clear cache" wasn't enough. Apparently "rebuild cache automatically" is more thorough and it worked after I enabled that option for a few seconds. It's perfect now!

Then you have an ownership/permission problem on your site where the cart can't clear the cache.  You should resolve this so other operations work correctly.  Note that cs-cart does very little error reporting for anything file or import/export based.  I.e. it's silent when problems are encountered.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • buging
  • Member
  • Members
  • Join Date: 12-Jan 11
  • 332 posts

Posted 23 December 2016 - 01:25 PM #69

Let's image that we should add the Royal Mail carrier. We will use royal_mail string as carrier identifier.

The tutorial is actual for CS-Cart and Multi-Vendor 4.x

1. Versions 4.0.x-4.2.x: Create the var/database/new_carrier.sql file with the following content:
Versions 4.3.x: Create the var/backups/new_carrier.sql file with the following content:
 

INSERT INTO ?:shipping_services (`status`, `module`, `code`, `sp_file`) VALUES ('A', 'royal_mail', '', '');
2. Versions 4.0.x-4.2.x: Log in the admin panel, go to Administration -> Database -> Restore page, select the
new_carrier.sql file and restore it.
Versions 4.3.x: Log in the admin panel, go to Administration -> Backup/Restore page, select the
new_carrier.sql file and restore it.

3. Go to Administration -> Languages -> Translations page and create new language variable:

Language variable: carrier_royal_mail ("carrier_" + carrier identifier)
Value: Royal Mail

4. Versions 4.3.5-4.3.x: Go to point #6

Versions 4.0.x-4.3.5: Edit the design/themes/THEME/templates/common/carriers.tpl file of your CS-Cart installation and replace this part of code:
 

{else}
with this one:

{elseif $carrier == "royal_mail"}
{$url = "http://www.royalmail.com/portal/rm/track?trackNumber=`$tracking_number`"}
{$carrier_name = __("royal_mail")}
{else}
where $url means the URL which enables your customers to see carrier delivery tracking information without the need to link to the carrier website. If you do not know such URL, just leave it empty:

{$url = ""}
5. Edit the design/themes/THEME/mail/templates/common/carriers.tpl file and apply the same changes there

 

6. Versions 4.3.5-4.3.x only (!)Open the app/schemas/shippings/carriers.php file and add:

'royal_mail' => array(
    'tracking_url_template' => 'http://www.royalmail.com/portal/rm/track?trackNumber=[tracking_number]',
),

after the following lines of code:

'usps' => array(
    'tracking_url_template' => 'https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=[tracking_number]',
),

7. Clear the cache ( Administration > Storage > Clear cache )

8. Check the result


See also:
- How To Add Custom Css With My Changes Addon
- How To Add Custom Javascript With My Changes Addon

Hope this can get updated for 4.4.x :)



 
  • Darius
  • Douchebag
  • Members
  • Join Date: 20-Apr 08
  • 3297 posts

Posted 23 December 2016 - 01:43 PM #70

using this

https://store.webkul...s-Tracking.html



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19782 posts

Posted 23 December 2016 - 01:54 PM #71

Hope this can get updated for 4.4.x :)

 

Unfortunately in 4.4.x versions carriers are linked with shipping services and corresponding functions does not have any hook. Bad style!


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Darius
  • Douchebag
  • Members
  • Join Date: 20-Apr 08
  • 3297 posts

Posted 23 December 2016 - 02:44 PM #72

Everything is getting more complex, not being able to specify link or remove unwanted carriers does not sound like a modern selling tool..



 
  • sunil0907
  • Member
  • Trial users
  • Join Date: 14-Sep 16
  • 47 posts

Posted 23 December 2016 - 10:39 PM #73

I was able to delete the unwanted carriers and add the new ones that I needed. But the problem now is when I create a shipment the hyperlink to the carriers website is not getting activated on the [tracking_number] like in previous versions.

Am I missing something to change. Please help



 
  • sunil0907
  • Member
  • Trial users
  • Join Date: 14-Sep 16
  • 47 posts

Posted 26 December 2016 - 07:14 AM #74

I was able to delete the unwanted carriers and add the new ones that I needed. But the problem now is when I create a shipment the hyperlink to the carriers website is not getting activated on the [tracking_number] like in previous versions.

Am I missing something to change. Please help

In versions 4.3.x the link to the carriers was defined in carriers.php by adding the following.

 

    'usps' => array(
        'tracking_url_template' => 'https://tools.usps.c...cking_number]',
    ),

 

In the new version 4.4.2 the file is no longer present. Can something throw some light on how and where the shipments can be linked to the carriers webpage.

 

Thanks,

Sunil



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19782 posts

Posted 26 December 2016 - 07:27 AM #75

In versions 4.3.x the link to the carriers was defined in carriers.php by adding the following.

 

    'usps' => array(
        'tracking_url_template' => 'https://tools.usps.c...cking_number]',
    ),

 

In the new version 4.4.2 the file is no longer present. Can something throw some light on how and where the shipments can be linked to the carriers webpage.

 

Thanks,

Sunil

 

As I said, carriers are linked with shipping services now. Please check the following directory:

 

app/Tygh/Shippings/Services

 

Each service has the "getInfo" function for getting tracking URL.

 

So there is no easy way to add new carriers in 4.4.x versions like it was earlier


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • straygecko
  • Advanced Member
  • Members
  • Join Date: 01-May 13
  • 93 posts

Posted 04 January 2017 - 09:26 PM #76

Unfortunately in 4.4.x versions carriers are linked with shipping services and corresponding functions does not have any hook. Bad style!

 

I hear you on that bad style.  Core classes need a well thought out method for addons to overrride them and inherit from the original class.  Then with a good method structure in the class it would be better than the existing hook structure.

 

Its a bit ugly but you can override the class and use inheritance to wrap the class methods.  It requires loading the shipping service code into a string, making a small patch to it and then eval it.  Not an ideal solution but it works.

 

app/addons/youraddon/init.php

<?php

if (!defined('BOOTSTRAP')) { die('Access denied'); }

use Tygh\Registry;

Registry::get('class_loader')->add('Tygh', Registry::get('config.dir.addons') . 'youraddon', true);

app/addons/youraddon/Tygh/Shippings/Services/Ups.php

<?php

namespace Tygh\Shippings\Services;

use Tygh\Registry;

if (!defined('BOOTSTRAP')) { die('Access denied'); }


// Patch the core cs-cart UPS class to new namespace so we can extend it
$coresource = file_get_contents(Registry::get('config.dir.root') . '/app/Tygh/Shippings/Services/Ups.php');
$coresource = str_replace('<?php', '', $coresource);
$coresource = str_replace('namespace Tygh\Shippings\Services;', 'namespace Tygh\Shippings\Services\core;', $coresource);
eval($coresource);

/**
 * UPS shipping service wrapper to implement youraddon
 */
class Ups extends \Tygh\Shippings\Services\core\Ups
{

    /**
     * Prepare request information
     *
     * @return array Prepared data
     */
    public function getRequestData()
    {
        $request_data = parent::getRequestData();

        /* tweak request data here */

        return $request_data;
          
    }

}

This requires some refinement if multiple addons need to do this to the same shipping service.

 

Adding a whole new shipping service is simpler using the same general idea.  Along with the proper database row being added just put the class loader line in your addon init and your new service in your addon Tygh/Shippings/Services directory.  No need for the patch/eval when its a new service.



 
  • straygecko
  • Advanced Member
  • Members
  • Join Date: 01-May 13
  • 93 posts

Posted 05 January 2017 - 05:39 PM #77

Following up on my last post, here's the example of how to add Royal Mail as a carrier in 4.4.x by creating an addon for Royal Mail.  Create these 3 files:

 

app/addons/royalmail/addon.xml

<?xml version="1.0"?>
<addon scheme='2.0' edition_type="ROOT,ULT:VENDOR">
    <id>royalmail</id>
    <version>1.0</version>
    <default_language>en</default_language>
    <name>Royal Mail Shipping Carrier</name>
    <description>Royal Mail Shipping Carrier</description>
    <priority>110</priority>
    <status>active</status>
    <queries>
        <item for="install">REPLACE INTO ?:shipping_services (`status`, `module`, `code`, `sp_file`) VALUES ('A', 'royalmail', '', '');</item>
        <item for="uninstall">DELETE FROM ?:shipping_services WHERE module = 'royalmail'</item>
    </queries>
    <language_variables>
        <item lang="en" id="carrier_royalmail">Royal Mail</item>
    </language_variables>
</addon>

app/addons/royalmail/init.php

<?php

if (!defined('BOOTSTRAP')) { die('Access denied'); }

use Tygh\Registry;

Registry::get('class_loader')->add('Tygh', Registry::get('config.dir.addons') . 'royalmail', true);

app/addons/royalmail/Tygh/Shippings/Services/Royalmail.php (make sure R in royalmail is capitalized)

<?php

namespace Tygh\Shippings\Services;

use Tygh\Shippings\IService;

/**
 * Royal Mail shipping service
 */
class Royalmail implements IService
{
    /**
     * Availability multithreading in this module
     *
     * @var array $_allow_multithreading
     */
    private $_allow_multithreading = true;

    /**
     * Returns shipping service information
     * @return array information
     */
    public static function getInfo()
    {
        return array(
            'name' => __('carrier_royalmail'),
            'tracking_url' => 'http://www.royalmail.com/portal/rm/track?trackNumber=%s'
        );
    }

    /**
     * Sets data to internal class variable
     *
     * @param array $shipping_info
     */
    public function prepareData($shipping_info)
    {
        $this->_shipping_info = $shipping_info;
    }

     /**
     * Gets shipping cost and information about possible errors
     *
     * @param  string $resonse Reponse from Shipping service server
     * @return array  Shipping cost and errors
     */
    public function processResponse($response)
    {
        $return = array(
            'cost' => false,
            'error' => false,
            'delivery_time' => false,
        );

        return $return;
    }

    /**
     * Gets error message from shipping service server
     *
     * @param  string $resonse Reponse from Shipping service server
     * @return string Text of error or false if no errors
     */
    public function processErrors($response)
    {
        return false;
    }

    /**
     * Checks if shipping service allows to use multithreading
     *
     * @return bool true if allow
     */
    public function allowMultithreading()
    {
        return $this->_allow_multithreading;
    }

    /**
     * Prepare request information
     *
     * @return array Prepared data
     */
    public function getRequestData()
    {
        return '';
    }

    /**
     * Process simple request to shipping service server
     *
     * @return string Server response
     */
    public function getSimpleRates()
    {
        return '';
    }

}

Note in this last file everything except the function getInfo are placeholders as cs-cart expects this to be a realtime rates service and requires those functions.  So don't try to use realtime rates for Royal Mail with this.  That would require a lot more development.

 

Now install the addon in your admin panel and you are good to go.



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19782 posts

Posted 06 January 2017 - 07:10 AM #78

straygecko, thank you for the detailed example

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • asourmelis
  • Newbie
  • Trial users
  • Join Date: 07-Nov 14
  • 11 posts

Posted 22 June 2017 - 08:05 AM #79

!!! This instruction will not work for CS-Cart and Multi-Vendor 4.4.1 and latest versions

 

Let's image that we should add the Royal Mail carrier. We will use royal_mail string as carrier identifier.

The tutorial is actual for CS-Cart and Multi-Vendor 4.x

1. Versions 4.0.x-4.2.x: Create the var/database/new_carrier.sql file with the following content:
Versions 4.3.x: Create the var/backups/new_carrier.sql file with the following content:
 

INSERT INTO ?:shipping_services (`status`, `module`, `code`, `sp_file`) VALUES ('A', 'royal_mail', '', '');

2. Versions 4.0.x-4.2.x: Log in the admin panel, go to Administration -> Database -> Restore page, select the
new_carrier.sql file and restore it.
Versions 4.3.x: Log in the admin panel, go to Administration -> Backup/Restore page, select the
new_carrier.sql file and restore it.

3. Go to Administration -> Languages -> Translations page and create new language variable:

Language variable: carrier_royal_mail ("carrier_" + carrier identifier)
Value: Royal Mail

4. Versions 4.3.5-4.3.x: Go to point #6

Versions 4.0.x-4.3.5: Edit the design/themes/THEME/templates/common/carriers.tpl file of your CS-Cart installation and replace this part of code:
 

{else}

with this one:
 

{elseif $carrier == "royal_mail"}
{$url = "http://www.royalmail.com/portal/rm/track?trackNumber=`$tracking_number`"}
{$carrier_name = __("royal_mail")}
{else}

where $url means the URL which enables your customers to see carrier delivery tracking information without the need to link to the carrier website. If you do not know such URL, just leave it empty:
 

{$url = ""}

5. Edit the design/themes/THEME/mail/templates/common/carriers.tpl file and apply the same changes there

 

6. Versions 4.3.5-4.3.x only (!)Open the app/schemas/shippings/carriers.php file and add:

'royal_mail' => array(
    'tracking_url_template' => 'http://www.royalmail.com/portal/rm/track?trackNumber=[tracking_number]',
),

after the following lines of code:

'usps' => array(
    'tracking_url_template' => 'https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=[tracking_number]',
),

7. Clear the cache ( Administration > Storage > Clear cache )

8. Check the result


See also:
- How To Add Custom Css With My Changes Addon
- How To Add Custom Javascript With My Changes Addon

If i want to remove one carrier how can i do that? For example in the list at the backend I have an entry that I did by accident called _carrier_new_carrier.



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19782 posts

Posted 22 June 2017 - 01:07 PM #80

If i want to remove one carrier how can i do that? For example in the list at the backend I have an entry that I did by accident called _carrier_new_carrier.

 

It depends on the CS-Cart version you use


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.