| 1 |
<?php |
| 2 |
/** |
| 3 |
* Add Bank Account Transfer Information. |
| 4 |
* |
| 5 |
* @package JupiterX_Core\sellkit |
| 6 |
* @since 1.2.8 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace Sellkit\Elementor\Modules\Order_Details\Items; |
| 10 |
|
| 11 |
defined( 'ABSPATH' ) || die(); |
| 12 |
|
| 13 |
use Elementor\Plugin as Elementor; |
| 14 |
|
| 15 |
/** |
| 16 |
* Shipping Method Item. |
| 17 |
* |
| 18 |
* Initializing the shipping method item by extending item base abstract class. |
| 19 |
* |
| 20 |
* @since 1.2.8 |
| 21 |
*/ |
| 22 |
class Bank_Transfer extends Item_Base { |
| 23 |
|
| 24 |
/** |
| 25 |
* Get Item class postfix. |
| 26 |
* |
| 27 |
* Retrieve the Item class postfix. |
| 28 |
* |
| 29 |
* @since 1.2.8 |
| 30 |
* @access public |
| 31 |
* |
| 32 |
* @return string Item class postfix. |
| 33 |
*/ |
| 34 |
public function get_class_name() { |
| 35 |
return 'bank'; |
| 36 |
} |
| 37 |
/** |
| 38 |
* Get Item type. |
| 39 |
* |
| 40 |
* Retrieve the Item type. |
| 41 |
* |
| 42 |
* @since 1.2.8 |
| 43 |
* @access public |
| 44 |
* |
| 45 |
* @return string Item type. |
| 46 |
*/ |
| 47 |
public function get_type() { |
| 48 |
return 'bank_transfer'; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Add render attribute. |
| 53 |
* |
| 54 |
* Add render attributes for each item based on the settings. |
| 55 |
* |
| 56 |
* @since 1.2.8 |
| 57 |
* @access public |
| 58 |
*/ |
| 59 |
public function add_field_render_attribute() { |
| 60 |
$attributes = [ |
| 61 |
'class' => 'order-details-item-content', |
| 62 |
'id' => 'order-details-' . $this->get_id(), |
| 63 |
]; |
| 64 |
|
| 65 |
$this->widget->add_render_attribute( 'order-details-item-' . $this->get_id(), $attributes ); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Render content. |
| 70 |
* |
| 71 |
* Render the item content. |
| 72 |
* |
| 73 |
* @since 1.2.8 |
| 74 |
* @access public |
| 75 |
* @param object $order_data Order data. |
| 76 |
*/ |
| 77 |
public function render_content( $order_data ) { |
| 78 |
$account_details = get_option( 'woocommerce_bacs_accounts' ); |
| 79 |
|
| 80 |
if ( 'bacs' !== $order_data['payment_method'] || empty( $account_details ) ) { |
| 81 |
return; |
| 82 |
} |
| 83 |
|
| 84 |
$content = '<section class="woocommerce-bacs-bank-details">'; |
| 85 |
|
| 86 |
foreach ( $account_details as $account_detail ) { |
| 87 |
$content .= '<h3 class="wc-bacs-bank-details order_details bacs_details">' . esc_html( $account_detail['account_name'] ) . '</h3>'; |
| 88 |
$content .= '<ul class="wc-bacs-bank-details order_details bacs_details">'; |
| 89 |
|
| 90 |
foreach ( $account_detail as $key => $detail ) { |
| 91 |
if ( empty( $detail ) ) { |
| 92 |
continue; |
| 93 |
} |
| 94 |
|
| 95 |
$title = esc_html( strtoupper( str_replace( '_', ' ', $key ) ) ); |
| 96 |
$class = esc_attr( str_replace( '_', '-', $key ) ); |
| 97 |
|
| 98 |
/* Translators: 1:className 2:title 3:value */ |
| 99 |
$content .= sprintf( |
| 100 |
'<li class="%1$s">%2$s<strong>%3$s</strong></li>', |
| 101 |
$class, |
| 102 |
$title, |
| 103 |
esc_html( $detail ) |
| 104 |
); |
| 105 |
} |
| 106 |
|
| 107 |
$content .= '</ul>'; |
| 108 |
} |
| 109 |
|
| 110 |
$content .= '</section>'; |
| 111 |
|
| 112 |
echo wp_kses_post( $content ); |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* Render dummy content. |
| 117 |
* |
| 118 |
* Render the Item dummy content. |
| 119 |
* |
| 120 |
* @since 1.2.8 |
| 121 |
* @access public |
| 122 |
*/ |
| 123 |
public function render_dummy_content() { |
| 124 |
?> |
| 125 |
<div> |
| 126 |
<?php echo esc_html__( 'Bank Details', 'sellkit' ); ?> |
| 127 |
</div> |
| 128 |
<?php |
| 129 |
} |
| 130 |
} |
| 131 |
|