2014-06-09 12 views

Odpowiedz

8

Pytanie dotyczyło wyłącznie celu dzielenia się wiedzą.

można zrozumieć kilka punktów z Ref_Link

// $order_id = Order ID 
$_order = Mage::getModel('sales/order')->load($order_id); 

if($_order->canShip()) 
{   
    $shipmentId = Mage::getModel('sales/order_shipment_api')->create($_order->getIncrementId(), $itemsarray ,'your_comment' ,false,1); 
    echo $shipmentId; // Outputs Shipment Increment Number 
    $trackmodel = Mage::getModel('sales/order_shipment_api') 
    ->addTrack($shipmentId,'your_shipping_carrier_code','your_shipping_carrier_title','carrier_tracking_number'); 
} 

$itemsarray = Format wyjaśnione tutaj Ref_link
to wszystko!
Prosty fragment kodu.
Mam nadzieję, że to komuś pomaga.

+0

Należy zauważyć, że $ shipmentId jest w rzeczywistości identyfikatorem przydziału wysyłek – kmdsax

1

Przyjęta odpowiedź jest prawidłowa i zadziałała u mnie w wersji CE 1.9, ale chciałem ją rozwinąć.

Nie musisz martwić się parametrem $itemsQty, możesz podać pusty array() lub całkowicie go opuścić. Jest to parametr opcjonalny, a metoda prepareShipment() sprawdza te dane i jeśli to konieczne, wykonuje wyszukiwanie.

Jeśli chcesz dołączyć numer śledzenia do e-maila wysyłkowego, najpierw dodaj śledzenie, a następnie użyj numeru Mage::getModel('sales/order_shipment_api')->sendInfo($shipmentIncrementId).

Code Snippet:

 $shipmentApi = Mage::getModel('sales/order_shipment_api'); 

     //pass false for email, unless you want Magento to send the shipment email without any tracking info 
     //could also be written as $shipmentIncrementId = $shipmentApi->create($order->getIncrementId()); 
     $shipmentIncrementId = $shipmentApi->create($order->getIncrementId(), array(), '' , false, 0); 

     //add tracking info ($shippingCarrier is case sensitive) 
     $shipmentApi->addTrack($shipmentIncrementId, $shippingCarrier, $shippingTitle, $trackingNumber); 

     //send shipment email with tracking info 
     $shipmentApi->sendInfo($shipmentIncrementId); 

create() metoda podpis:

public function create($orderIncrementId, $itemsQty = array(), $comment = null, 
               $email = false, $includeComment = false) 

Zobacz app\code\core\Mage\Sales\Model\Order\Shipment\Api.php dla wszystkich metod.

Powiązane problemy