WC_Product::backorders_require_notification PHP 메소드

backorders_require_notification() 공개 메소드

Returns whether or not the product needs to notify the customer on backorder.
    public function backorders_require_notification()
    {
        return apply_filters('woocommerce_product_backorders_require_notification', $this->managing_stock() && 'notify' === $this->get_backorders(), $this);
    }

Usage Example

 /**
  * Bundled product availability that takes quantity into account.
  *
  * @param  WC_Product   $product    the product
  * @param  int          $quantity   the quantity
  * @return array                    availability data
  */
 function get_bundled_product_availability($product, $quantity)
 {
     $availability = $class = '';
     if ($product->managing_stock()) {
         if ($product->is_in_stock() && $product->get_total_stock() > get_option('woocommerce_notify_no_stock_amount') && $product->get_total_stock() >= $quantity) {
             switch (get_option('woocommerce_stock_format')) {
                 case 'no_amount':
                     $availability = __('In stock', 'woocommerce');
                     break;
                 case 'low_amount':
                     if ($product->get_total_stock() <= get_option('woocommerce_notify_low_stock_amount')) {
                         $availability = sprintf(__('Only %s left in stock', 'woocommerce'), $product->get_total_stock());
                         if ($product->backorders_allowed() && $product->backorders_require_notification()) {
                             $availability .= ' ' . __('(can be backordered)', 'woocommerce');
                         }
                     } else {
                         $availability = __('In stock', 'woocommerce');
                     }
                     break;
                 default:
                     $availability = sprintf(__('%s in stock', 'woocommerce'), $product->get_total_stock());
                     if ($product->backorders_allowed() && $product->backorders_require_notification()) {
                         $availability .= ' ' . __('(can be backordered)', 'woocommerce');
                     }
                     break;
             }
             $class = 'in-stock';
         } elseif ($product->backorders_allowed() && $product->backorders_require_notification()) {
             if ($product->get_total_stock() >= $quantity || get_option('woocommerce_stock_format') == 'no_amount') {
                 $availability = __('Available on backorder', 'woocommerce');
             } else {
                 $availability = __('Available on backorder', 'woocommerce') . ' ' . sprintf(__('(only %s left in stock)', 'woocommerce-product-bundles'), $product->get_total_stock());
             }
             $class = 'available-on-backorder';
         } elseif ($product->backorders_allowed()) {
             $availability = __('In stock', 'woocommerce');
             $class = 'in-stock';
         } else {
             if ($product->is_in_stock() && $product->get_total_stock() > get_option('woocommerce_notify_no_stock_amount')) {
                 if (get_option('woocommerce_stock_format') == 'no_amount') {
                     $availability = __('Insufficient stock', 'woocommerce-product-bundles');
                 } else {
                     $availability = __('Insufficient stock', 'woocommerce-product-bundles') . ' ' . sprintf(__('(only %s left in stock)', 'woocommerce-product-bundles'), $product->get_total_stock());
                 }
                 $class = 'out-of-stock';
             } else {
                 $availability = __('Out of stock', 'woocommerce');
                 $class = 'out-of-stock';
             }
         }
     } elseif (!$product->is_in_stock()) {
         $availability = __('Out of stock', 'woocommerce');
         $class = 'out-of-stock';
     }
     _deprecated_function('get_bundled_product_availability', '4.8.8', 'WC_Bundled_Item::get_availability()');
     return apply_filters('woocommerce_get_bundled_product_availability', array('availability' => $availability, 'class' => $class), $product);
 }
All Usage Examples Of WC_Product::backorders_require_notification
WC_Product