| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main ProductDescription class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\Single; |
| 9 |
|
| 10 |
// Do not allow directly accessing this file. |
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit( 'This script cannot be accessed directly.' ); |
| 13 |
} |
| 14 |
|
| 15 |
use RadiusTheme\SB\Abstracts\LoopWithProductSlider; |
| 16 |
|
| 17 |
/** |
| 18 |
* Product Description class |
| 19 |
*/ |
| 20 |
class RelatedProduct extends LoopWithProductSlider { |
| 21 |
|
| 22 |
/** |
| 23 |
* Construct function |
| 24 |
* |
| 25 |
* @param array $data default array. |
| 26 |
* @param mixed $args default arg. |
| 27 |
*/ |
| 28 |
public function __construct( $data = [], $args = null ) { |
| 29 |
$this->rtsb_base = 'rtsb-related-product'; |
| 30 |
$this->rtsb_name = esc_html__( 'Related Product - Default', 'shopbuilder' ); |
| 31 |
parent::__construct( $data, $args ); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Apply hooks function. |
| 36 |
* |
| 37 |
* @return void |
| 38 |
*/ |
| 39 |
public function apply_hooks() { |
| 40 |
parent::apply_hooks(); |
| 41 |
$controllers = $this->get_settings_for_display(); |
| 42 |
add_filter( 'woocommerce_output_related_products_args', [ $this, 'products_args' ] ); |
| 43 |
if ( empty( $controllers['show_title'] ) ) { |
| 44 |
add_filter( 'woocommerce_product_related_products_heading', '__return_false' ); |
| 45 |
} elseif ( ! empty( $controllers['loop_title_text'] ) ) { |
| 46 |
add_filter( |
| 47 |
'woocommerce_product_related_products_heading', |
| 48 |
function( $text ) use ( $controllers ) { |
| 49 |
return $controllers['loop_title_text']; |
| 50 |
} |
| 51 |
); |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Widget Selector |
| 57 |
* |
| 58 |
* @return array |
| 59 |
*/ |
| 60 |
public function template_data_arg() { |
| 61 |
return [ |
| 62 |
'template' => 'elementor/single-product/related-product', |
| 63 |
]; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
} |
| 68 |
|