0

i use backorder for some products ut change add to cart text to backorder text its apply to all product types & list,product detail,search list page.Also any event to know backorder products before load html?Kindly reply me

2 Answers 2

1

For change at Product view page, need to change at addtocart.phtml at catalog/product/view/

check current product has backorder or not change according to it

if($_product->getStockItem()->getBackorders()!=0){
$buttonTitle=$this->__('Backorder');
}

Same type logic need for category and search page .to check current product has getBackorders and change according to it. If $productObejct->getStockItem()->getBackorders()!=0) then it means backorder avalibale

0
<?php

$obj = \Magento\Framework\App\ObjectManager::getInstance();  
$stockRegistry = $obj->get('Magento\CatalogInventory\Api\StockRegistryInterface');
$stockitem = $stockRegistry->getStockItem($_product->getId(),$_product->getStore()->getWebsiteId());

  if($stockitem->getBackorders() == 1):
    $buttonTitle = __('Backorders');
  else:
    $buttonTitle = __('Add to Cart');
  endif;

?>

Your Answer

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

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