Как вы удаляете транзитное время из способов доставки USPS?


Предложение по доставке от USPS отображается примерно так:

Приоритетная почта за 1 день $6,60

Как правильно изменить это, чтобы оно отображалось только как "Приоритетная почта"?

Author: callmedpit, 2014-07-07

2 answers

У нас была та же проблема с USPS, поэтому мы создали модуль, который переопределяет функцию _filterServiceName(). Это позволяет нам избавиться от любой информации типа "количество дней", с возможностью изменять ее в каждом магазине от администратора, и нет необходимости вручную добавлять каждый "перевод", как в другом ответе предполагает.

App/code/local/YourNamespace/Usps/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <YourNamespace_Usps>
            <version>0.0.1</version>
        </YourNamespace_Usps>
    </modules>
    <global>
        <models>
            <usa>
                <rewrite>
                    <shipping_carrier_usps>YourNamespace_Usps_Model_Usa_Shipping_Carrier_Usps</shipping_carrier_usps>
                </rewrite>
            </usa>
        </models>
    </global>
</config>

App/code/local/YourNamespace/Usps/Model/Usa/Shipping/Carrier/Usps.php

<?php
class YourNamespace_Usps_Model_Usa_Shipping_Carrier_Usps extends Mage_Usa_Model_Shipping_Carrier_Usps {
    function _filterServiceName($name) {
        $name = parent::_filterServiceName($name);


        if( !Mage::getStoreConfig('carriers/usps/show_number_of_days') )
            $name = preg_replace('/\s+?\d+-day/i', '', $name); // Trim out the number of days, and an optional leading space.

        return $name;
    }
}

App/code/local/YourNamespace/Usps/etc/system.xml

<config>
    <sections>
        <carriers>
            <groups>
                <usps>
                    <fields>
                        <show_number_of_days translate="label">
                            <label>Show Number of Days</label>
                            <comment>If set to "No", "Priority Mail 3-Day", "Priority Mail 2-Day" and "Priority Mail 4-Day" will all show up as "Priority Mail".</comment>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>129</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </show_number_of_days>
                    </fields>
                </usps>
            </groups>
        </carriers>
    </sections>
</config>

App/etc/modules/YourNamespace_Usps.xml

<?xml version="1.0"?>
<config>
    <modules>
        <YourNamespace_Usps>
            <active>true</active>
            <codePool>local</codePool>
        </YourNamespace_Usps>
    </modules>
</config>

Раздел конфигурации

Config Section

Перед:

Before

После:

After

 4
Author: Eric Seastrand, 2015-04-09 19:28:06

Ответ в: переопределить имя метода доставки USPS.

Сделайте копию app/code/core/Mage/Sales/Model/Quote/Address/Rate.php чтобы app/code/community/Mage/Sales/Model/Quote/Address/Rate.php

Затем замените

->setMethodTitle($rate->getMethodTitle())

С

->setMethodTitle(Mage::helper('shipping')->__($rate->getMethodTitle()))

И добавьте соответствующие переводы в файл Mage_Shipping.csv.

Ч/Т Жду ответа.

Обратите внимание, что я не смог заставить это работать в 1.6.2, но это отлично работает в 1.9.0.1

 1
Author: provence shop, 2017-04-13 12:55:02