0

I'm trying to get the price of a specific sku if it exists on an order, here's what my current code is:

$itemCollection = $order->getItemsCollection();
    foreach($itemCollection as $item) {
        $sku = $item->sku;
        if($sku == 'MySku') {
            $price = $item->getPrice;
        }
    }

I believe $price = $item->getPrice; is incorrect, I'm just not sure how to grab the line-item price for MySku from the order.

Any help would be great, thanks!

1 Answer 1

0

There's a few errors in your code. Also we can't know in which file you're trying to execute this code so I couldn't test it.

$itemCollection = $order->getItemsCollection();
foreach($itemCollection as $item) {
    $sku = $item->getSku();
    if($sku == 'MySku') {
        $price = $item->getPrice();
    }
}
1
  • Thanks, I'll give that a shot -- I'll provide more code if I can't get this snippet to work.
    – AJK
    Aug 2, 2016 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.