| @@ 663-722 (lines=60) @@ | ||
| 660 | * |
|
| 661 | * @return string |
|
| 662 | */ |
|
| 663 | public function get_availability() { |
|
| 664 | $availability = $class = ''; |
|
| 665 | ||
| 666 | if ( $this->managing_stock() ) { |
|
| 667 | ||
| 668 | if ( $this->is_in_stock() && $this->get_total_stock() > get_option( 'woocommerce_notify_no_stock_amount' ) ) { |
|
| 669 | ||
| 670 | switch ( get_option( 'woocommerce_stock_format' ) ) { |
|
| 671 | ||
| 672 | case 'no_amount' : |
|
| 673 | $availability = __( 'In stock', 'woocommerce' ); |
|
| 674 | break; |
|
| 675 | ||
| 676 | case 'low_amount' : |
|
| 677 | if ( $this->get_total_stock() <= get_option( 'woocommerce_notify_low_stock_amount' ) ) { |
|
| 678 | $availability = sprintf( __( 'Only %s left in stock', 'woocommerce' ), $this->get_total_stock() ); |
|
| 679 | ||
| 680 | if ( $this->backorders_allowed() && $this->backorders_require_notification() ) { |
|
| 681 | $availability .= ' ' . __( '(can be backordered)', 'woocommerce' ); |
|
| 682 | } |
|
| 683 | } else { |
|
| 684 | $availability = __( 'In stock', 'woocommerce' ); |
|
| 685 | } |
|
| 686 | break; |
|
| 687 | ||
| 688 | default : |
|
| 689 | $availability = sprintf( __( '%s in stock', 'woocommerce' ), $this->get_total_stock() ); |
|
| 690 | ||
| 691 | if ( $this->backorders_allowed() && $this->backorders_require_notification() ) { |
|
| 692 | $availability .= ' ' . __( '(can be backordered)', 'woocommerce' ); |
|
| 693 | } |
|
| 694 | break; |
|
| 695 | } |
|
| 696 | ||
| 697 | $class = 'in-stock'; |
|
| 698 | ||
| 699 | } elseif ( $this->backorders_allowed() && $this->backorders_require_notification() ) { |
|
| 700 | ||
| 701 | $availability = __( 'Available on backorder', 'woocommerce' ); |
|
| 702 | $class = 'available-on-backorder'; |
|
| 703 | ||
| 704 | } elseif ( $this->backorders_allowed() ) { |
|
| 705 | ||
| 706 | $availability = __( 'In stock', 'woocommerce' ); |
|
| 707 | $class = 'in-stock'; |
|
| 708 | ||
| 709 | } else { |
|
| 710 | ||
| 711 | $availability = __( 'Out of stock', 'woocommerce' ); |
|
| 712 | $class = 'out-of-stock'; |
|
| 713 | } |
|
| 714 | ||
| 715 | } elseif ( ! $this->is_in_stock() ) { |
|
| 716 | ||
| 717 | $availability = __( 'Out of stock', 'woocommerce' ); |
|
| 718 | $class = 'out-of-stock'; |
|
| 719 | } |
|
| 720 | ||
| 721 | return apply_filters( 'woocommerce_get_availability', array( 'availability' => $availability, 'class' => $class ), $this ); |
|
| 722 | } |
|
| 723 | ||
| 724 | /** |
|
| 725 | * Returns whether or not the product is featured. |
|
| @@ 530-575 (lines=46) @@ | ||
| 527 | * |
|
| 528 | * @return string |
|
| 529 | */ |
|
| 530 | public function get_availability() { |
|
| 531 | $availability = $class = ''; |
|
| 532 | ||
| 533 | if ( $this->managing_stock() ) { |
|
| 534 | if ( $this->is_in_stock() && $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount' ) ) { |
|
| 535 | switch ( get_option( 'woocommerce_stock_format' ) ) { |
|
| 536 | case 'no_amount' : |
|
| 537 | $availability = __( 'In stock', 'woocommerce' ); |
|
| 538 | break; |
|
| 539 | case 'low_amount' : |
|
| 540 | if ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_low_stock_amount' ) ) { |
|
| 541 | $availability = sprintf( __( 'Only %s left in stock', 'woocommerce' ), $this->get_stock_quantity() ); |
|
| 542 | ||
| 543 | if ( $this->backorders_allowed() && $this->backorders_require_notification() ) { |
|
| 544 | $availability .= ' ' . __( '(can be backordered)', 'woocommerce' ); |
|
| 545 | } |
|
| 546 | } else { |
|
| 547 | $availability = __( 'In stock', 'woocommerce' ); |
|
| 548 | } |
|
| 549 | break; |
|
| 550 | default : |
|
| 551 | $availability = sprintf( __( '%s in stock', 'woocommerce' ), $this->get_stock_quantity() ); |
|
| 552 | ||
| 553 | if ( $this->backorders_allowed() && $this->backorders_require_notification() ) { |
|
| 554 | $availability .= ' ' . __( '(can be backordered)', 'woocommerce' ); |
|
| 555 | } |
|
| 556 | break; |
|
| 557 | } |
|
| 558 | $class = 'in-stock'; |
|
| 559 | } elseif ( $this->backorders_allowed() && $this->backorders_require_notification() ) { |
|
| 560 | $availability = __( 'Available on backorder', 'woocommerce' ); |
|
| 561 | $class = 'available-on-backorder'; |
|
| 562 | } elseif ( $this->backorders_allowed() ) { |
|
| 563 | $availability = __( 'In stock', 'woocommerce' ); |
|
| 564 | $class = 'in-stock'; |
|
| 565 | } else { |
|
| 566 | $availability = __( 'Out of stock', 'woocommerce' ); |
|
| 567 | $class = 'out-of-stock'; |
|
| 568 | } |
|
| 569 | } elseif ( ! $this->is_in_stock() ) { |
|
| 570 | $availability = __( 'Out of stock', 'woocommerce' ); |
|
| 571 | $class = 'out-of-stock'; |
|
| 572 | } |
|
| 573 | ||
| 574 | return apply_filters( 'woocommerce_get_availability', array( 'availability' => $availability, 'class' => $class ), $this ); |
|
| 575 | } |
|
| 576 | ||
| 577 | /** |
|
| 578 | * Returns whether or not the product needs to notify the customer on backorder. |
|