カートの製品が発売されているかどうかを確認する方法(特別価格があります)?
-
12-12-2019 - |
質問
カートの中の特別価格ですべての製品にアイコンを追加しようとしています。誰もがそれをする方法を考えましたか?リストや製品のカートでやるのは簡単でしたが、今は立ち往生しています。
解決
あなたは以下のコードでこれを行うことができます:
if($product->getPrice()>$product->getFinalPrice()):
// product in sales
endif;
.
$specialprice = $product->getSpecialPrice();
$specialPriceFromDate = $product->getSpecialFromDate();
$specialPriceToDate = $product->getSpecialToDate();
$today = time();
if ($specialprice && ($product->getPrice()>$product->getFinalPrice())):
if($today >= strtotime( $specialPriceFromDate) && $today <= strtotime($specialPriceToDate) ||
$today >= strtotime( $specialPriceFromDate) && is_null($specialPriceToDate)):
//product in sales
endif;
endif;
. 所属していません magento.stackexchange