AbstractProductListBlock.php
2 months ago
ProductListBlock.php
2 months ago
ProductPageBlock.php
2 months ago
ProductReviewBlock.php
4 months ago
ProductReviewListBlock.php
4 months ago
RelatedProductsBlock.php
2 months ago
ProductReviewBlock.php
74 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Models\Blocks; |
| 4 | |
| 5 | /** |
| 6 | * The product review block. |
| 7 | */ |
| 8 | class ProductReviewBlock { |
| 9 | /** |
| 10 | * The URL. |
| 11 | * |
| 12 | * @var object |
| 13 | */ |
| 14 | protected $url; |
| 15 | |
| 16 | /** |
| 17 | * Constructor. |
| 18 | */ |
| 19 | public function __construct() { |
| 20 | $this->url = \SureCart::block()->urlParams(); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Get the URL. |
| 25 | * |
| 26 | * @return object|null |
| 27 | */ |
| 28 | public function urlParams() { |
| 29 | return $this->url; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Get the context. |
| 34 | * |
| 35 | * @param array $context The context to add to the existing context. |
| 36 | * |
| 37 | * @return array |
| 38 | */ |
| 39 | public function context( $context = [] ) { |
| 40 | $product = sc_get_product(); |
| 41 | if ( empty( $product ) ) { |
| 42 | return []; |
| 43 | } |
| 44 | |
| 45 | return wp_parse_args( |
| 46 | $context, |
| 47 | array( |
| 48 | 'busy' => false, |
| 49 | ), |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Get the state. |
| 55 | * |
| 56 | * @param array $state The state to add to the existing state. |
| 57 | * |
| 58 | * @return array |
| 59 | */ |
| 60 | public function state( $state = [] ) { |
| 61 | $product = sc_get_product(); |
| 62 | if ( empty( $product ) ) { |
| 63 | return []; |
| 64 | } |
| 65 | |
| 66 | return wp_parse_args( |
| 67 | $state, |
| 68 | [ |
| 69 | 'busy' => false, |
| 70 | ] |
| 71 | ); |
| 72 | } |
| 73 | } |
| 74 |