1

Question: I need to know if a product is bought with special price or not.

More Background: We are using three prices for our products, which are original price, special price and tier price. We have integrated Magento with another system, called Linx. This system needs to know if the price is a special price, or not.

When I look at the sales_order_item table, I can list the following fields related with the price:

  • price
  • base_price
  • original_price
  • base_original_price
  • price_incl_tax
  • base_price_incl_tax
  • discount_percent
  • discount_amount

Paraphrased Question: How can I say that one of these fields hold special price for sure?

0

add below dependency

protected $orderRepository;

public function __construct(
    ...
    \Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
    ....
) {
    ....
    $this->orderRepository = $orderRepository;
    ....
}

use below code in function where you want to get price

$order = $this->orderRepository->get($orderId);
foreach ($order->getAllItems() as $item) {
 $price = $item->getPrice(); //discount price
}
| improve this answer | |
  • 1
    I think I need to be more clear. How can I be sure that this is not a tier price? $item->getPrice() is the price that customer paid. But can we confirm that if it is special price, or not? – Bunyamin Inan Nov 9 '17 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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