Here’s the whole page. It outputs something like this:
Shipment ID 37006
Fedex #12345678
Shipment ID 37014
USPS #12345678
then under address details etc it shows the items in the order
Product #1
Product #2
Product #3
What I’m trying to do is add the products that where shipped to the tracking number.
[code]
<?php
$order = $this->getTrackOrder();
$shipTrack = array();
if ($order) {
$shipments = $order->getShipmentsCollection();
foreach ($shipments as $shipment) {
$increment_id = $shipment->getIncrementId();
$tracks = $shipment->getTracksCollection();
$trackingInfos = array();
foreach ($tracks as $track) {
$trackingInfos[] = $track->getNumberDetail();
}
$shipTrack[$increment_id] = $trackingInfos;
}
}
$order_id = $order['increment_id'];
$order_item = Mage::getModel("sales/order")->loadByIncrementId($order_id);
$items = $order_item->getItemsCollection();
$order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id);
$colspan = $rowspan = 2;
$shipping_method = $order_details->_data["shipping_description"];
$shipping_address_data = $order_details->getShippingAddress();
$billingAddress = $order_details->getBillingAddress();
$shippcode = $order_details->getShippingAddress()->getCountry();
$billcode = $order_details->getBillingAddress()->getCountry();
$paymentmethod = $order->getPayment()->getMethodInstance()->getTitle();
$payarry = $order->getPayment()->debug();
foreach (Mage::getSingleton('payment/config')->getCcTypes() as $code => $name) {
if ($payarry['cc_type'] == $code) {
$options = $name;
}
}
$pending = Mage::getStoreConfig('trackorder/trackorder_orderstatus/pending');
$processing = Mage::getStoreConfig('trackorder/trackorder_orderstatus/processing');
$complete = Mage::getStoreConfig('trackorder/trackorder_orderstatus/complete');
$canceled = Mage::getStoreConfig('trackorder/trackorder_orderstatus/canceled');
$closed = Mage::getStoreConfig('trackorder/trackorder_orderstatus/closed');
$pending_class = $processing_class = $complete_pclass = $canceled_class = $closed_class = "";
if ($order->getStatusLabel() == 'Pending') {
$pending_class = '
![]()
';
}
if ($order->getStatusLabel() == 'Processing') {
$processing_class = '
![]()
';
}
if ($order->getStatusLabel() == 'Complete') {
$complete_pclass = '
![]()
';
}
if ($order->getStatusLabel() == 'Canceled') {
$canceled_class = '
![]()
';
}
if ($order->getStatusLabel() == 'Closed') {
$closed_class = '
![]()
';
}
?>
<?php $_results = $shipTrack; ?>
<?php echo $this->__('Tracking Information'); ?>
<?php
if ($pending)
echo $pending;
else
echo $pending_class;
?>
<?php
if ($processing)
echo $processing;
else
echo $processing_class;
?>
<?php
if ($complete)
echo $complete;
else
echo $complete_pclass;
?>
<?php
if ($canceled)
echo $canceled;
else
echo $canceled_class;
?>
<?php
if ($closed)
echo $closed;
else
echo $closed_class;
?>
<?php echo $this->__("Your Order Status is :") ?> <?php echo $order->getStatusLabel() ?>
<?php
error_reporting(-1);
ini_set('display_errors', 'true');
function fred( $val )
{
echo '
'; print_r( $val ); echo '
';
}
fred($_results);
foreach ($_results as $shipid => $shipment_S )
{
fred( $shipment_S);
foreach($shipment_S as $shipment)
{
fred( $shipment);
foreach ($shipment->getAllItems() as $_product)
{
fred( $_product);
echo $_product->getName() . $shipid . "
";
}
}
}
?>
<?php if (sizeof($_results) > 0): ?>
<?php foreach ($_results as $shipid => $_result): ?>
<?php if ($shipid): ?>
<h4><?php echo $this->__('Shipment #') . $shipid; ?></h4>
<?php endif; ?>
<?php if (sizeof($_result) > 0): ?>
<?php
$rowCount = sizeof($_result);
$counter = 1;
?>
<?php foreach ($_result as $track): ?>
<table class="data-table track-data-table">
<col width="15%" />
<col />
<tbody>
<?php if (is_object($track)): ?>
<tr>
<th><?php echo $this->__('Tracking Number:'); ?></th>
<td><?php echo $track->getTracking(); ?></td>
</tr>
<?php if ($track->getCarrierTitle()): ?>
<tr>
<th><?php echo $this->__('Carrier:'); ?></th>
<td><?php echo $track->getCarrierTitle(); ?></td>
</tr>
<?php endif; ?>
<?php if ($track->getErrorMessage()): ?>
<tr>
<th><?php echo $this->__('Error:'); ?></th>
<td class="error"><?php if ((bool) Mage::getStoreConfig('contacts/contacts/enabled')) : ?><a href="<?php echo $this->getUrl('contacts') ?>" onclick="this.target = '_blank'"><?php echo $this->__('Click here') ?></a><?php
echo $this->__(' to get details or ');
endif;
echo $this->__('email us at ');
?><a href="mailto:<?php echo Mage::getStoreConfig('trans_email/ident_support/email'); ?>"><?php echo Mage::getStoreConfig('trans_email/ident_support/email') ?></a>
</td>
</tr>
<?php elseif ($track->getTrackSummary()): ?>
<tr>
<th><?php echo $this->__('Info:'); ?></th>
<td><?php echo $track->getTrackSummary(); ?></td>
</tr>
<?php elseif ($track->getUrl()): ?>
<tr>
<th><?php echo $this->__('Track:'); ?></th>
<td><a href="<?php echo $track->getUrl(); ?>" onclick="this.target = '_blank'"><?php echo $this->__('Click here to get details'); ?></a></td>
</tr>
<?php else: ?>
<?php if ($track->getStatus()): ?>
<tr>
<th><?php echo $this->__('Status:'); ?></th>
<td><?php echo $track->getStatus(); ?></td>
</tr>
<?php endif; ?>
<?php if ($track->getDeliverydate()): ?>
<tr>
<th><?php echo $this->__('Delivered on:'); ?></th>
<td><?php echo $this->formatDeliveryDateTime($track->getDeliverydate(), $track->getDeliverytime()); ?></td>
</tr>
<?php endif; ?>
<?php if ($track->getSignedby()): ?>
<tr>
<th><?php echo $this->__('Signed by:'); ?></th>
<td><?php echo $track->getSignedby(); ?></td>
</tr>
<?php endif; ?>
<?php if ($track->getDeliveryLocation()): ?>
<tr>
<th><?php echo $this->__('Delivered to:'); ?></th>
<td><?php echo $track->getDeliveryLocation(); ?></td>
</tr>
<?php endif; ?>
<?php if ($track->getShippedDate()): ?>
<tr>
<th><?php echo $this->__('Shipped or billed on:'); ?></th>
<td><?php echo $track->getShippedDate(); ?></td>
</tr>
<?php endif; ?>
<?php if ($track->getService()): ?>
<tr>
<th><?php echo $this->__('Service Type:'); ?></th>
<td><?php echo $track->getService(); ?></td>
</tr>
<?php endif; ?>
<?php if ($track->getWeight()): ?>
<tr>
<th><?php echo $this->__('Weight:'); ?></th>
<td><?php echo $track->getWeight(); ?></td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php elseif (isset($track['title']) && isset($track['number']) && $track['number']): ?>
<!--if the tracking is custom value-->
<tr>
<th><?php echo ($track['title'] ? $this->escapeHtml($track['title']) : $this->__('N/A')); ?>:</th>
<td><?php echo (isset($track['number']) ? $this->escapeHtml($track['number']) : ''); ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php if (is_object($track) && sizeof($track->getProgressdetail()) > 0): ?>
<table class="data-table" id="track-history-table-<?php echo $track->getTracking(); ?>">
<col />
<col width="1" />
<col width="1" />
<col />
<thead>
<tr>
<th><?php echo $this->__('Location') ?></th>
<th><?php echo $this->__('Date') ?></th>
<th><?php echo $this->__('Local Time') ?></th>
<th><?php echo $this->__('Description') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($track->getProgressdetail() as $_detail): ?>
<?php $_detailDate = (isset($_detail['deliverydate']) ? $this->formatDeliveryDate($_detail['deliverydate']) : '') ?>
<?php $_detailTime = (isset($_detail['deliverytime']) ? $this->formatDeliveryTime($_detail['deliverytime'], $_detailDate) : '') ?>
<tr>
<td><?php echo (isset($_detail['deliverylocation']) ? $_detail['deliverylocation'] : ''); ?></td>
<td><?php echo $_detailDate ?></td>
<td><?php echo $_detailTime ?></td>
<td><?php echo (isset($_detail['activity']) ? $_detail['activity'] : '') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('track-history-table-<?php echo $track->getTracking(); ?>');</script>
<?php endif; ?>
<?php if ($counter != $rowCount): ?>
<?php endif; ?>
<?php $counter++; ?>
<?php endforeach; ?>
<!--end for each tracking information-->
<?php else: ?>
<p><?php echo $this->__('There is no tracking available for this shipment.'); ?></p>
<?php endif; ?>
<?php endforeach; ?>
<?php else: ?>
<div><?php echo $this->__('There is no tracking available.'); ?></div>
<?php endif; ?>
Order Information
<?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) : ?>
<?php echo $this->__('
here to print', $this->getPrintUrl()) ?>
<?php ?>
<?php endif; ?>
Date:
<?php echo $order_item->getCreatedAtStoreDate(); ?>
Order ID:
<?php echo $order_id; ?>
Order Total:
<?php echo $order_item->getGrandTotal(); ?>
Payment & Shipping Information
Shipping Method:
<?php echo $shipping_method; ?>
Payment Method:
<?php echo $paymentmethod; ?>
<?php if ($paymentmethod == 'Credit Card (saved)') { ?>
Credit Card Type:
<?php echo $options; ?>
Credit Card Number:
<?php echo $payarry['cc_last4']; ?>
Credit Card Owner:
<?php echo $payarry['cc_owner']; ?>
<?php } ?>
Shipping Address
Name:
<?php echo $shipping_address_data['firstname'] . " " . $shipping_address_data['lastname']; ?>
Delivery Address:
<?php echo $shipping_address_data['street']; ?>
Delivery City:
<?php echo $shipping_address_data['city']; ?>
State:
<?php echo $shipping_address_data['region']; ?>
Country:
<?php echo Mage::app()->getLocale()->getCountryTranslation($shippcode); ?>
Postcode:
<?php echo $shipping_address_data['postcode']; ?>
Telephone:
<?php echo $shipping_address_data['telephone']; ?>
Billing Address
Name:
<?php echo $billingAddress['firstname'] . " " . $billingAddress['lastname']; ?>
Delivery Address:
<?php echo $billingAddress['street']; ?>
Delivery City:
<?php echo $billingAddress['city']; ?>
State:
<?php echo $billingAddress['region']; ?>
Country:
<?php echo Mage::app()->getLocale()->getCountryTranslation($billcode); ?>
Postcode:
<?php echo $billingAddress['postcode']; ?>
Telephone:
<?php echo $billingAddress->getTelephone(); ?>
<?php echo $this->getChildHtml('totals'); ?>
<?php
foreach ($items as $i):
$_product = Mage::getModel('catalog/product')->load($i->getProductId());
$options = $i->getProductOptions();
?>
<?php echo $this->__('Product Name') ?> |
<?php echo $this->__('Unit Price') ?> |
<?php echo $this->__('Qty') ?> |
<?php echo $this->__('SKU') ?> |
<?php echo $this->__('Sub Total') ?> |
<?php
echo $i->getName();
$customOptions = $options['options'];
if (!empty($customOptions)) {
foreach ($customOptions as $option) {
?>
<span class="bottom-align">
<?php
echo '<b>' . $option['label'] . '</b> :';
echo $optionValue = $option['value'];
?></span>
<?php
}
}
?>
</div>
</td>
<td><?php echo $this->helper('checkout')->formatPrice($i->getPrice()); ?></td>
<td><?php echo $i->getQtyOrdered(); ?></td>
<td><?php echo $i->getSku(); ?></td>
<td><?php echo $this->helper('checkout')->formatPrice($i->getRowTotal()); ?></td>
</tr>
<?php endforeach ?>
</tbody>
<tfoot>
<tr>
<td colspan="4" class="a-right">
<small>SubTotal:</small>
</td>
<td colspan="2" class="a-right">
<small><?php echo $this->helper('checkout')->formatPrice($order_item->getSubtotal()); ?></small>
</td>
</tr>
<tr class="shipping">
<td class="a-right" colspan="4">
<?php echo $this->__('Shipping & Handling(' . $order_item->getShippingDescription() . ')'); ?>
</td>
<td colspan="2" class="last a-right">
<span class="subtotlal-value">
<?php echo $this->helper('checkout')->formatPrice($order_item->getShippingInclTax()); ?>
</span>
</td>
</tr>
<?php if ($order_item->getDiscountAmount() != 0): ?>
<tr class="discount">
<td class="a-right" colspan="4">
<?php echo $this->__('Discount'); echo $order_item->getDiscountDescription() ? '('.$order_item->getDiscountDescription() .')' : ""; ?>
</td>
<td class="last a-right">
<span class="subtotlal-value">
<?php echo $this->helper('checkout')->formatPrice($order_item->getDiscountAmount()); ?>
</span>
</td>
</tr><?php
endif;
?>
<tr class="grand_total last">
<td class="a-right" colspan="4"><strong><?php echo $this->__('Total') ?></strong></td>
<td colspan="2" class="last a-right">
<span class="subtotlal-value">
<strong><?php echo $this->helper('checkout')->formatPrice($order_item->getGrandTotal()); ?></strong>
</span>
</td>
</tr>
</tfoot>
</table>
[/code] |