| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main ProductDescription class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\Cart; |
| 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\Traits\ActionBtnTraits; |
| 16 |
use RadiusTheme\SB\Abstracts\LoopWithProductSlider; |
| 17 |
|
| 18 |
/** |
| 19 |
* Product Description class |
| 20 |
*/ |
| 21 |
class CrossSellProduct extends LoopWithProductSlider { |
| 22 |
/** |
| 23 |
* Action Button Traits. |
| 24 |
*/ |
| 25 |
use ActionBtnTraits; |
| 26 |
/** |
| 27 |
* Construct function |
| 28 |
* |
| 29 |
* @param array $data default array. |
| 30 |
* @param mixed $args default arg. |
| 31 |
*/ |
| 32 |
public function __construct( $data = [], $args = null ) { |
| 33 |
$this->rtsb_base = 'rtsb-cross-sells'; |
| 34 |
parent::__construct( $data, $args ); |
| 35 |
$this->rtsb_name = esc_html__( 'Cross Sell - Default Layout', 'shopbuilder' ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Apply hooks function. |
| 40 |
* |
| 41 |
* @return void |
| 42 |
*/ |
| 43 |
public function apply_hooks() { |
| 44 |
parent::apply_hooks(); |
| 45 |
$controllers = $this->get_settings_for_display(); |
| 46 |
if ( empty( $controllers['show_title'] ) ) { |
| 47 |
add_filter( 'woocommerce_product_cross_sells_products_heading', '__return_false' ); |
| 48 |
} elseif ( ! empty( $controllers['loop_title_text'] ) ) { |
| 49 |
add_filter( |
| 50 |
'woocommerce_product_cross_sells_products_heading', |
| 51 |
function( $text ) use ( $controllers ) { |
| 52 |
return $controllers['loop_title_text']; |
| 53 |
} |
| 54 |
); |
| 55 |
} |
| 56 |
if ( $this->is_builder_mode() ) { |
| 57 |
wc_load_cart(); |
| 58 |
} |
| 59 |
} |
| 60 |
/** |
| 61 |
* Widget Selector |
| 62 |
* |
| 63 |
* @return array |
| 64 |
*/ |
| 65 |
public function template_data_arg() { |
| 66 |
$controllers = $this->get_settings_for_display(); |
| 67 |
$limit = ! empty( $controllers['posts_per_page'] ) ? absint( $controllers['posts_per_page'] ) : 2; |
| 68 |
$columns = ! empty( $controllers['columns'] ) ? absint( $controllers['columns'] ) : 2; |
| 69 |
$order_by = ! empty( $controllers['orderby'] ) ? $controllers['orderby'] : 'rand'; |
| 70 |
$p_order = ! empty( $controllers['order'] ) ? $controllers['order'] : 'desc'; |
| 71 |
return [ |
| 72 |
'template' => 'elementor/cart/cross-sells', |
| 73 |
'is_builder' => $this->is_builder_mode(), |
| 74 |
'limit' => $limit, |
| 75 |
'columns' => $columns, |
| 76 |
'order_by' => $order_by, |
| 77 |
'p_order' => $p_order, |
| 78 |
]; |
| 79 |
} |
| 80 |
|
| 81 |
} |
| 82 |
|