Magento Checkout success page product price and SKU retrival

Magento Checkout success page product price and SKU retrival

July 13, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento Checkout success page product price and SKU retrival

Retrieving Product SKU and Price on Magento Checkout Success Page

As an e-commerce developer, I often receive requests to integrate third-party services like Commission Junction into our clients’ Magento sites. One common requirement is to pass the SKUs and prices of all purchased products after a successful checkout.

In this post, we’ll explore how to retrieve these product details on the Magento checkout success page using the built-in order model and some code snippets.

Understanding the Magento Checkout Process

Magento processes the checkout in several stages. After the customer submits their order, Magento creates an order object with all the necessary information, including the associated products.

The success page (checkout_onepage_success) is displayed after a successful transaction. On this page, we have access to the current order object through the getLastRealOrderId function provided by the Mage::registry helper.

Retrieving the Order Object

To get started, let’s retrieve the latest order object on the success page.

<?php
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order   = Mage::getModel('sales/order')->load($orderId);
?>

In this code snippet:

  • We first get the last real order ID from the checkout session.
  • Then, we load the corresponding sales order object using the load method of the sales_order model.

Accessing Associated Products

Now that we have the order object, we can access all the associated products. Each product is represented as a separate item in the order’s items collection.

<?php foreach ($order->getItemsCollection() as $item): ?>
    <p>SKU: <?php echo $item->getSku(); ?></p>
    <p>Price: <?php echo Mage::helper('core')->currency($item->getRowTotal()); ?></p>
<?php endforeach; ?>

In this loop:

  • We use the getItemsCollection method to get all items (products) associated with the order.
  • For each item, we display the SKU using the getSku method and the price using the getRowTotal method.

Passing Product Details to Third-Party Services

To pass these product details to your Commission Junction integration, you’ll need to include them in the form data or AJAX calls as required by their API documentation. The provided SKU and price values can be used directly in this process.

Best Practices for Integrations on Magento Success Page

When integrating third-party services like Commission Junction on the success page:

  • Always validate the order object before processing any data.
  • Handle exceptions that might occur during the loading of the order or access to its items.
  • Ensure your code adheres to Magento’s coding standards and best practices.

Conclusion

Retrieving product SKUs and prices after a successful checkout in Magento is straightforward once you understand how the order objects are structured. By using the built-in sales_order model, we can easily access all associated products and their details on the success page.

Remember, every integration will have its unique requirements, so always refer to the third-party service’s documentation for the exact format they expect the data in.

If you need professional help with Magento integrations or development services, feel free to reach out to our team at Laravel Company.

Happy coding!

Checkout Catalog Orders Customers

Our network