first commit
This commit is contained in:
@@ -0,0 +1,712 @@
|
||||
<?php
|
||||
|
||||
namespace Essential_Addons_Elementor\Template\Woocommerce\Cart;
|
||||
|
||||
use Elementor\Icons_Manager;
|
||||
use \Essential_Addons_Elementor\Classes\Helper;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
trait Woo_Cart_Helper {
|
||||
|
||||
public static $setting_data = [];
|
||||
|
||||
public static function ea_get_woo_cart_settings() {
|
||||
return self::$setting_data;
|
||||
}
|
||||
|
||||
public static function ea_set_woo_cart_settings( $settings ) {
|
||||
self::$setting_data = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Added all actions
|
||||
*/
|
||||
public function ea_woo_cart_add_actions( $settings ) {
|
||||
// set ea cart controller settings
|
||||
self::ea_set_woo_cart_settings( $settings );
|
||||
}
|
||||
|
||||
public function ea_cart_render() {
|
||||
$settings = self::ea_get_woo_cart_settings();
|
||||
Woo_Cart_Shortcode::output( [], $settings );
|
||||
}
|
||||
|
||||
public static function woo_cart_style_one( $settings ) { ?>
|
||||
<form class="woocommerce-cart-form eael-woo-cart-form woocommerce" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
|
||||
<?php do_action( 'woocommerce_before_cart_table' ); ?>
|
||||
|
||||
<div class="eael-cart-clear-btn mt10">
|
||||
<?php if ( ! empty( $settings['eael_woo_cart_components_cart_clear_button'] ) && $settings['eael_woo_cart_components_cart_clear_button'] === 'yes' ) {
|
||||
$clear_text = apply_filters( 'eael_woo_cart_clear_button_text', $settings['eael_woo_cart_components_cart_clear_button_text'] );
|
||||
echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" class="button" title="' . esc_attr( $clear_text ) . '">' . esc_html( $clear_text ) . '</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="eael-woo-cart-table-warp">
|
||||
<table class="shop_table cart woocommerce-cart-form__contents eael-woo-cart-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
if ( ! empty( $settings['table_items'] ) && is_array( $settings['table_items'] ) ) {
|
||||
foreach ( $settings['table_items'] as $column_data ) {
|
||||
$item_class = "elementor-repeater-item-{$column_data['_id']}";
|
||||
?>
|
||||
<th class="<?php echo esc_attr( "product-{$column_data['column_type']} {$item_class}" ); ?>">
|
||||
<?php
|
||||
$title = apply_filters( "eael_woo_cart_table_{$column_data['column_type']}_title", $column_data['column_heading_title'] );
|
||||
echo esc_html( $title );
|
||||
?>
|
||||
</th>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
do_action( 'woocommerce_before_cart_contents' );
|
||||
|
||||
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
||||
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
|
||||
|
||||
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0
|
||||
&& apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key )
|
||||
) {
|
||||
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink',
|
||||
$_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item,
|
||||
$cart_item_key );
|
||||
?>
|
||||
<tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class',
|
||||
'cart_item', $cart_item, $cart_item_key ) ); ?>">
|
||||
<?php
|
||||
if ( ! empty( $settings['table_items'] ) && is_array( $settings['table_items'] ) ) {
|
||||
foreach ( $settings['table_items'] as $column_data ) {
|
||||
$item_class = "elementor-repeater-item-{$column_data['_id']}";
|
||||
|
||||
switch ( $column_data['column_type'] ) {
|
||||
case 'remove': ?>
|
||||
<td class="product-remove <?php echo esc_attr( $item_class ); ?>">
|
||||
<?php
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'woocommerce_cart_item_remove_link',
|
||||
sprintf(
|
||||
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">%s</a>',
|
||||
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
|
||||
esc_html__( 'Remove this item', 'essential-addons-for-elementor-lite' ),
|
||||
esc_attr( $product_id ),
|
||||
esc_attr( $_product->get_sku() ),
|
||||
Helper::get_render_icon( $column_data['item_remove_icon'], [ 'aria-hidden' => 'true' ] )
|
||||
),
|
||||
$cart_item_key
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
case 'thumbnail': ?>
|
||||
<td class="product-thumbnail <?php echo esc_attr( $item_class ); ?>">
|
||||
<?php
|
||||
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
|
||||
|
||||
if ( ! $product_permalink ) {
|
||||
echo $thumbnail; // PHPCS: XSS ok.
|
||||
} else {
|
||||
printf( '<a href="%s">%s</a>', esc_url( $product_permalink ),
|
||||
$thumbnail ); // PHPCS: XSS ok.
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
case 'name': ?>
|
||||
<td class="product-name <?php echo esc_attr( $item_class ); ?>">
|
||||
<?php
|
||||
if ( ! $product_permalink ) {
|
||||
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name',
|
||||
$_product->get_name(), $cart_item, $cart_item_key )
|
||||
. ' ' );
|
||||
} else {
|
||||
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name',
|
||||
sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ),
|
||||
$_product->get_name() ), $cart_item, $cart_item_key ) );
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
|
||||
|
||||
// Meta data.
|
||||
echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok.
|
||||
|
||||
// Backorder notification.
|
||||
if ( $_product->backorders_require_notification()
|
||||
&& $_product->is_on_backorder( $cart_item['quantity'] )
|
||||
) {
|
||||
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification',
|
||||
'<p class="backorder_notification">'
|
||||
. esc_html__( 'Available on backorder', 'essential-addons-for-elementor-lite' )
|
||||
. '</p>', $product_id ) );
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
case 'price': ?>
|
||||
<td class="product-price <?php echo esc_attr( $item_class ); ?>">
|
||||
<?php
|
||||
echo apply_filters( 'woocommerce_cart_item_price',
|
||||
WC()->cart->get_product_price( $_product ), $cart_item,
|
||||
$cart_item_key ); // PHPCS: XSS ok.
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
case 'quantity': ?>
|
||||
<td class="product-quantity <?php echo esc_attr( $item_class ); ?>">
|
||||
<?php
|
||||
if ( $_product->is_sold_individually() ) {
|
||||
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
|
||||
} else {
|
||||
$product_quantity = woocommerce_quantity_input(
|
||||
[
|
||||
'input_name' => "cart[{$cart_item_key}][qty]",
|
||||
'input_value' => $cart_item['quantity'],
|
||||
'max_value' => $_product->get_max_purchase_quantity(),
|
||||
'min_value' => '0',
|
||||
'product_name' => $_product->get_name(),
|
||||
],
|
||||
$_product,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity,
|
||||
$cart_item_key, $cart_item ); // PHPCS: XSS ok.
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
case 'subtotal': ?>
|
||||
<td class="product-subtotal <?php echo esc_attr( $item_class ); ?>">
|
||||
<?php
|
||||
echo apply_filters( 'woocommerce_cart_item_subtotal',
|
||||
WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ),
|
||||
$cart_item,
|
||||
$cart_item_key ); // PHPCS: XSS ok.
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_cart_contents' );
|
||||
do_action( 'woocommerce_after_cart_contents' ); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
do_action( 'woocommerce_after_cart_table' );
|
||||
self::woo_cart_collaterals( $settings );
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function eael_woo_cart_totals( $settings ) {
|
||||
if ( ! empty( $settings['ea_woo_cart_layout'] ) ) {
|
||||
?>
|
||||
<div class="cart_totals <?php echo ( WC()->customer->has_calculated_shipping() ) ? 'calculated_shipping' : ''; ?>">
|
||||
<?php
|
||||
do_action( 'woocommerce_before_cart_totals' );
|
||||
|
||||
if ( $settings['eael_woo_cart_components_cart_totals_subtotal'] === 'yes' || $settings['eael_woo_cart_components_cart_totals_coupon'] === 'yes' ||
|
||||
$settings['eael_woo_cart_components_cart_totals_shipping'] === 'yes' ||
|
||||
( ! empty( WC()->cart->get_fees() ) && $settings['eael_woo_cart_components_cart_totals_fees'] === 'yes' ) ||
|
||||
$settings['eael_woo_cart_components_cart_totals_tax'] === 'yes' || $settings['eael_woo_cart_components_cart_totals_total'] === 'yes' ) {
|
||||
?>
|
||||
<table class="shop_table shop_table_responsive">
|
||||
|
||||
<?php if ( $settings['eael_woo_cart_components_cart_totals_subtotal'] === 'yes' ) {
|
||||
$subtotal_label = apply_filters( 'eael_woo_cart_totals_subtotal_label', esc_html__( 'Subtotal', 'essential-addons-for-elementor-lite' ) );
|
||||
?>
|
||||
<tr class="cart-subtotal">
|
||||
<th><?php echo esc_html( $subtotal_label ); ?></th>
|
||||
<td data-title="<?php echo esc_attr( $subtotal_label ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if ( $settings['eael_woo_cart_components_cart_totals_coupon'] === 'yes' ) {
|
||||
foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
|
||||
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
|
||||
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
|
||||
<td data-title="<?php echo esc_attr( wc_cart_totals_coupon_label( $coupon, false ) ); ?>"><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( $settings['eael_woo_cart_components_cart_totals_shipping'] === 'yes' ) {
|
||||
if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
|
||||
|
||||
<?php do_action( 'woocommerce_cart_totals_before_shipping' ); ?>
|
||||
|
||||
<?php wc_cart_totals_shipping_html(); ?>
|
||||
|
||||
<?php do_action( 'woocommerce_cart_totals_after_shipping' ); ?>
|
||||
|
||||
<?php elseif ( WC()->cart->needs_shipping() && 'yes' === get_option( 'woocommerce_enable_shipping_calc' ) ) :
|
||||
$shipping_label = apply_filters( 'eael_woo_cart_totals_shipping_label', esc_html__( 'Shipping', 'essential-addons-for-elementor-lite' ) );
|
||||
?>
|
||||
|
||||
<tr class="shipping">
|
||||
<th><?php echo esc_html( $shipping_label ); ?></th>
|
||||
<td data-title="<?php echo esc_attr( $shipping_label ); ?>"><?php woocommerce_shipping_calculator(); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
} ?>
|
||||
|
||||
<?php
|
||||
if ( $settings['eael_woo_cart_components_cart_totals_fees'] === 'yes' ) {
|
||||
foreach ( WC()->cart->get_fees() as $fee ) : ?>
|
||||
<tr class="fee">
|
||||
<th><?php echo esc_html( $fee->name ); ?></th>
|
||||
<td data-title="<?php echo esc_attr( $fee->name ); ?>"><?php wc_cart_totals_fee_html( $fee ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
} ?>
|
||||
|
||||
<?php
|
||||
if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() && $settings['eael_woo_cart_components_cart_totals_tax'] === 'yes' ) {
|
||||
$taxable_address = WC()->customer->get_taxable_address();
|
||||
$estimated_text = '';
|
||||
|
||||
if ( WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping() ) {
|
||||
/* translators: %s location. */
|
||||
$estimated_text = sprintf( ' <small>' . esc_html__( '(estimated for %s)', 'essential-addons-for-elementor-lite' ) . '</small>', WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] );
|
||||
}
|
||||
|
||||
if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) {
|
||||
foreach ( WC()->cart->get_tax_totals() as $code => $tax ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
?>
|
||||
<tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
|
||||
<th><?php echo esc_html( $tax->label ) . $estimated_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th>
|
||||
<td data-title="<?php echo esc_attr( $tax->label ); ?>"><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<tr class="tax-total">
|
||||
<th><?php echo esc_html( WC()->countries->tax_or_vat() ) . $estimated_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th>
|
||||
<td data-title="<?php echo esc_attr( WC()->countries->tax_or_vat() ); ?>"><?php wc_cart_totals_taxes_total_html(); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
do_action( 'woocommerce_cart_totals_before_order_total' );
|
||||
|
||||
if ( $settings['eael_woo_cart_components_cart_totals_total'] === 'yes' ) {
|
||||
$total_label = apply_filters( 'eael_woo_cart_totals_total_label', esc_html__( 'Total', 'essential-addons-for-elementor-lite' ) );
|
||||
?>
|
||||
<tr class="order-total">
|
||||
<th><?php echo esc_html( $total_label ); ?></th>
|
||||
<td data-title="<?php echo esc_attr( $total_label ); ?>"><?php wc_cart_totals_order_total_html(); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_cart_totals_after_order_total' );
|
||||
?>
|
||||
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="wc-proceed-to-checkout">
|
||||
<?php do_action( 'woocommerce_proceed_to_checkout', $settings ); ?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
do_action( 'woocommerce_after_cart_totals' ); ?>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
woocommerce_cart_totals();
|
||||
}
|
||||
}
|
||||
|
||||
public function remove_woocommerce_cross_sell_display( $settings ) {
|
||||
// Remove default 'woocommerce_cross_sell_display' callback from 'woocommerce_cart_collaterals'
|
||||
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
|
||||
}
|
||||
|
||||
public static function eael_cart_button_proceed_to_checkout( $settings ) {
|
||||
if ( ! empty( $settings['ea_woo_cart_layout'] ) ) {
|
||||
$button_text = apply_filters( 'eael_woo_cart_checkout_button_text', $settings['eael_woo_cart_components_cart_checkout_button_text'] );
|
||||
?>
|
||||
<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="checkout-button button alt wc-forward">
|
||||
<?php echo esc_html( $button_text ); ?>
|
||||
</a>
|
||||
<?php
|
||||
} else {
|
||||
woocommerce_button_proceed_to_checkout();
|
||||
}
|
||||
}
|
||||
|
||||
public static function woo_cart_style_two( $settings ) { ?>
|
||||
<form class="woocommerce-cart-form eael-woo-cart-form woocommerce" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
|
||||
<?php do_action( 'woocommerce_before_cart_table' ); ?>
|
||||
|
||||
<div class="eael-cart-clear-btn mt10">
|
||||
<?php if ( ! empty( $settings['eael_woo_cart_components_cart_clear_button'] ) && $settings['eael_woo_cart_components_cart_clear_button'] === 'yes' ) {
|
||||
$clear_text = apply_filters( 'eael_woo_cart_clear_button_text', $settings['eael_woo_cart_components_cart_clear_button_text'] );
|
||||
echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" class="button" title="' . esc_attr( $clear_text ) . '">' . esc_html( $clear_text ) . '</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="shop_table cart woocommerce-cart-form__contents eael-woo-cart-table">
|
||||
<?php
|
||||
$has_table_left_components = $settings['eael_woo_cart_table_components_thumbnail'] === 'yes' ? true : false;
|
||||
$has_table_right_components = in_array( 'yes', [
|
||||
$settings['eael_woo_cart_table_components_price'],
|
||||
$settings['eael_woo_cart_table_components_qty'],
|
||||
$settings['eael_woo_cart_table_components_subtotal'],
|
||||
$settings['eael_woo_cart_table_components_remove']
|
||||
] ) ? true : false;
|
||||
|
||||
if ( $has_table_left_components || $has_table_right_components ) {
|
||||
?>
|
||||
<div class="eael-woo-cart-thead">
|
||||
<div class="eael-woo-cart-tr">
|
||||
<?php if ( $has_table_left_components ) { ?>
|
||||
<div class="eael-woo-cart-tr-left">
|
||||
<div class="eael-woo-cart-td product-thumbnail">
|
||||
<?php
|
||||
$title = apply_filters( "eael_woo_cart_table_thumbnail_title", $settings['eael_woo_cart_table_components_thumbnail_title'] );
|
||||
echo esc_html( $title );
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $has_table_right_components ) { ?>
|
||||
<div class="eael-woo-cart-tr-right">
|
||||
<?php if ( $settings['eael_woo_cart_table_components_price'] === 'yes' ) { ?>
|
||||
<div class="eael-woo-cart-td product-price">
|
||||
<?php
|
||||
$title = apply_filters( "eael_woo_cart_table_price_title", $settings['eael_woo_cart_table_components_price_title'] );
|
||||
echo esc_html( $title );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $settings['eael_woo_cart_table_components_qty'] === 'yes' ) { ?>
|
||||
<div class="eael-woo-cart-td product-quantity">
|
||||
<?php
|
||||
$title = apply_filters( "eael_woo_cart_table_quantity_title", $settings['eael_woo_cart_table_components_qty_title'] );
|
||||
echo esc_html( $title );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $settings['eael_woo_cart_table_components_subtotal'] === 'yes' ) { ?>
|
||||
<div class="eael-woo-cart-td product-subtotal">
|
||||
<?php
|
||||
$title = apply_filters( "eael_woo_cart_table_subtotal_title", $settings['eael_woo_cart_table_components_subtotal_title'] );
|
||||
echo esc_html( $title );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $settings['eael_woo_cart_table_components_remove'] === 'yes' ) { ?>
|
||||
<div class="eael-woo-cart-td product-remove"></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="eael-woo-cart-tbody">
|
||||
<?php
|
||||
do_action( 'woocommerce_before_cart_contents' );
|
||||
|
||||
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
||||
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
|
||||
|
||||
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0
|
||||
&& apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key )
|
||||
) {
|
||||
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink',
|
||||
$_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item,
|
||||
$cart_item_key );
|
||||
?>
|
||||
<div class="eael-woo-cart-tr woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class',
|
||||
'cart_item', $cart_item, $cart_item_key ) ); ?>">
|
||||
<?php if ( $has_table_left_components ) { ?>
|
||||
<div class="eael-woo-cart-tr-left">
|
||||
<div class="eael-woo-cart-td product-thumbnail">
|
||||
<?php
|
||||
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
|
||||
|
||||
if ( ! $product_permalink ) {
|
||||
echo $thumbnail; // PHPCS: XSS ok.
|
||||
} else {
|
||||
printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok.
|
||||
}
|
||||
|
||||
if ( $settings['eael_woo_cart_table_components_remove'] === 'yes' ) { ?>
|
||||
<div class="eael-woo-cart-product-remove">
|
||||
<?php
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'woocommerce_cart_item_remove_link',
|
||||
sprintf(
|
||||
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">%s</a>',
|
||||
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
|
||||
esc_html__( 'Remove this item', 'essential-addons-for-elementor-lite' ),
|
||||
esc_attr( $product_id ),
|
||||
esc_attr( $_product->get_sku() ),
|
||||
Helper::get_render_icon( $settings['eael_woo_cart_table_components_remove_icon'], [ 'aria-hidden' => 'true' ] )
|
||||
),
|
||||
$cart_item_key
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php }
|
||||
?>
|
||||
</div>
|
||||
<?php if ( $settings['eael_woo_cart_table_components_name'] === 'yes' ) { ?>
|
||||
<div class="eael-woo-cart-td product-name">
|
||||
<?php
|
||||
if ( ! $product_permalink ) {
|
||||
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' ' );
|
||||
} else {
|
||||
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ),
|
||||
$_product->get_name() ), $cart_item, $cart_item_key ) );
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
|
||||
|
||||
// Product SKU
|
||||
if ( $settings['eael_woo_cart_table_components_sku'] === 'yes' && ! empty( $_product->get_sku() ) ) {
|
||||
printf( '<p class="eael-woo-cart-sku">#%s</p>', $_product->get_sku() );
|
||||
}
|
||||
|
||||
// Meta data.
|
||||
echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok.
|
||||
|
||||
// Backorder notification.
|
||||
if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
|
||||
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification',
|
||||
'<p class="backorder_notification">'
|
||||
. esc_html__( 'Available on backorder', 'essential-addons-for-elementor-lite' )
|
||||
. '</p>', $product_id ) );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $has_table_right_components ) { ?>
|
||||
<div class="eael-woo-cart-tr-right">
|
||||
<?php if ( $settings['eael_woo_cart_table_components_price'] === 'yes' ) { ?>
|
||||
<div class="eael-woo-cart-td product-price">
|
||||
<?php
|
||||
echo apply_filters( 'woocommerce_cart_item_price',
|
||||
WC()->cart->get_product_price( $_product ), $cart_item,
|
||||
$cart_item_key ); // PHPCS: XSS ok.
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $settings['eael_woo_cart_table_components_qty'] === 'yes' ) { ?>
|
||||
<div class="eael-woo-cart-td product-quantity">
|
||||
<?php
|
||||
if ( $_product->is_sold_individually() ) {
|
||||
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
|
||||
} else {
|
||||
$product_quantity = woocommerce_quantity_input(
|
||||
[
|
||||
'input_name' => "cart[{$cart_item_key}][qty]",
|
||||
'input_value' => $cart_item['quantity'],
|
||||
'max_value' => $_product->get_max_purchase_quantity(),
|
||||
'min_value' => '0',
|
||||
'product_name' => $_product->get_name(),
|
||||
],
|
||||
$_product,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity,
|
||||
$cart_item_key, $cart_item ); // PHPCS: XSS ok.
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $settings['eael_woo_cart_table_components_subtotal'] === 'yes' ) { ?>
|
||||
<div class="eael-woo-cart-td product-subtotal" data-title="<?php echo esc_html( $title ); ?>">
|
||||
<?php
|
||||
echo apply_filters( 'woocommerce_cart_item_subtotal',
|
||||
WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ),
|
||||
$cart_item,
|
||||
$cart_item_key ); // PHPCS: XSS ok.
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $settings['eael_woo_cart_table_components_remove'] === 'yes' ) { ?>
|
||||
<div class="eael-woo-cart-td product-remove">
|
||||
<?php
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'woocommerce_cart_item_remove_link',
|
||||
sprintf(
|
||||
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">%s</a>',
|
||||
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
|
||||
esc_html__( 'Remove this item', 'essential-addons-for-elementor-lite' ),
|
||||
esc_attr( $product_id ),
|
||||
esc_attr( $_product->get_sku() ),
|
||||
Helper::get_render_icon( $settings['eael_woo_cart_table_components_remove_icon'], [ 'aria-hidden' => 'true' ] )
|
||||
),
|
||||
$cart_item_key
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_cart_contents' );
|
||||
do_action( 'woocommerce_after_cart_contents' ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
do_action( 'woocommerce_after_cart_table' );
|
||||
self::woo_cart_collaterals( $settings );
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function woo_cart_collaterals( $settings ) { ?>
|
||||
<div class="eael-cart-coupon-and-collaterals">
|
||||
<div class="eael-cart-coupon-wrapper">
|
||||
<?php if ( wc_coupons_enabled() && $settings['eael_woo_cart_components_cart_coupon'] === 'yes' ) {
|
||||
$button_text = apply_filters( 'eael_woo_cart_coupon_button_text', $settings['eael_woo_cart_components_cart_coupon_button_text'] );
|
||||
$placeholder = apply_filters( 'eael_woo_cart_coupon_placeholder', $settings['eael_woo_cart_components_cart_coupon_placeholder'] );
|
||||
$coupon_label = apply_filters( 'eael_woo_cart_coupon_label_text', esc_html__( 'Coupon:', 'essential-addons-for-elementor-lite' ) );
|
||||
?>
|
||||
<div class="coupon">
|
||||
<label for="coupon_code" class="sr-only"><?php echo esc_html( $coupon_label ); ?></label>
|
||||
<input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php echo esc_attr( $placeholder ); ?>"/>
|
||||
<button type="submit" class="button" name="apply_coupon"
|
||||
value="<?php echo esc_attr( $button_text ); ?>"><?php echo esc_html( $button_text ); ?></button>
|
||||
<?php do_action( 'woocommerce_cart_coupon' ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $settings['eael_woo_cart_components_continue_shopping'] === 'yes' ) {
|
||||
$continue_shopping_text = apply_filters( 'eael_woo_cart_continue_shopping_text', $settings['eael_woo_cart_components_continue_shopping_text'] );
|
||||
printf( '<a class="eael-woo-cart-back-to-shop" href="%s">%s %s</a>',
|
||||
get_permalink( wc_get_page_id( 'shop' ) ),
|
||||
Helper::get_render_icon( $settings['eael_woo_cart_components_continue_shopping_icon'], [ 'aria-hidden' => 'true' ] ),
|
||||
esc_html( $continue_shopping_text )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_before_cart_collaterals' ); ?>
|
||||
|
||||
<div class="cart-collaterals">
|
||||
<div class="eael-cart-update-btn">
|
||||
<?php if ( $settings['eael_woo_cart_components_cart_update_button'] === 'yes' ) {
|
||||
$update_text = apply_filters( 'eael_woo_cart_update_button_text', $settings['eael_woo_cart_components_cart_update_button_text'] );
|
||||
?>
|
||||
<button type="submit" class="button" name="update_cart" value="<?php echo esc_attr( $update_text ); ?>"><?php echo esc_html( $update_text ); ?></button>
|
||||
<?php
|
||||
}
|
||||
else if ( ! $settings['eael_woo_cart_components_cart_update_button'] && $settings['eael_woo_cart_auto_cart_update'] === 'yes' ){
|
||||
echo '<button type="submit" class="button" name="update_cart" style="display:none;"></button>';
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_cart_actions' );
|
||||
wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Cart collaterals hook.
|
||||
*
|
||||
* @hooked woocommerce_cross_sell_display
|
||||
* @hooked woocommerce_cart_totals - 10
|
||||
*/
|
||||
|
||||
do_action( 'eael_woocommerce_before_cart_collaterals', $settings );
|
||||
|
||||
if ( $settings['eael_woo_cart_components_cart_totals'] === 'yes' ) {
|
||||
do_action( 'woocommerce_cart_collaterals', $settings );
|
||||
} else {
|
||||
?>
|
||||
<div class="cart_totals">
|
||||
<div class="wc-proceed-to-checkout">
|
||||
<?php do_action( 'woocommerce_proceed_to_checkout', $settings ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function wc_empty_cart_message( $message ) {
|
||||
$settings = self::ea_get_woo_cart_settings();
|
||||
$empty_text = $settings['eael_woo_cart_components_empty_cart_text'];
|
||||
|
||||
return empty( $empty_text ) ? $message : esc_html( $empty_text );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Essential_Addons_Elementor\Template\Woocommerce\Cart;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if ( class_exists( '\WC_Shortcode_Cart' ) ) {
|
||||
class Woo_Cart_Shortcode extends \WC_Shortcode_Cart {
|
||||
|
||||
use Woo_Cart_Helper;
|
||||
|
||||
/**
|
||||
* Output the cart shortcode.
|
||||
*
|
||||
* @param array $atts Shortcode attributes.
|
||||
*/
|
||||
public static function output( $atts, $settings = [] ) {
|
||||
if ( ! apply_filters( 'woocommerce_output_cart_shortcode_content', true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Constants.
|
||||
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
||||
|
||||
$atts = shortcode_atts( [], $atts, 'woocommerce_cart' );
|
||||
$nonce_value = wc_get_var( $_REQUEST['woocommerce-shipping-calculator-nonce'],
|
||||
wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.
|
||||
|
||||
// Update Shipping. Nonce check uses new value and old value (woocommerce-cart). @todo remove in 4.0.
|
||||
if ( ! empty( $_POST['calc_shipping'] )
|
||||
&& ( wp_verify_nonce( $nonce_value, 'woocommerce-shipping-calculator' )
|
||||
|| wp_verify_nonce( $nonce_value, 'woocommerce-cart' ) )
|
||||
) { // WPCS: input var ok.
|
||||
self::calculate_shipping();
|
||||
|
||||
// Also calc totals before we check items so subtotals etc are up to date.
|
||||
WC()->cart->calculate_totals();
|
||||
}
|
||||
|
||||
// Check cart items are valid.
|
||||
do_action( 'woocommerce_check_cart_items' );
|
||||
|
||||
// Calc totals.
|
||||
WC()->cart->calculate_totals();
|
||||
$auto_update = $settings['eael_woo_cart_auto_cart_update'] === 'yes' ? 'eael-auto-update' : '';
|
||||
if ( WC()->cart->is_empty() ) { ?>
|
||||
<div class="eael-woo-cart-wrapper eael-woo-cart-empty <?php echo esc_attr( printf( '%s %s', "eael-woo-{$settings['ea_woo_cart_layout']}", $auto_update ) ); ?>">
|
||||
<?php wc_get_template( 'cart/cart-empty.php' ); ?>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
$style_two_wrapper_class = '';
|
||||
if ( $settings['ea_woo_cart_layout'] === 'style-2' ) {
|
||||
if ( $settings['eael_woo_cart_table_components_thumbnail'] === 'yes' ) {
|
||||
$style_two_wrapper_class .= ' has-table-left-content';
|
||||
}
|
||||
|
||||
if ( in_array( 'yes', [
|
||||
$settings['eael_woo_cart_table_components_price'],
|
||||
$settings['eael_woo_cart_table_components_qty'],
|
||||
$settings['eael_woo_cart_table_components_subtotal'],
|
||||
$settings['eael_woo_cart_table_components_remove']
|
||||
] ) ) {
|
||||
$style_two_wrapper_class .= ' has-table-right-content';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="eael-woo-cart-wrapper <?php echo esc_attr( sprintf( '%s %s %s', "eael-woo-{$settings['ea_woo_cart_layout']}", $auto_update, $style_two_wrapper_class ) ); ?>">
|
||||
<?php
|
||||
do_action( 'woocommerce_before_cart' );
|
||||
|
||||
switch ( $settings['ea_woo_cart_layout'] ) {
|
||||
case 'default':
|
||||
self::woo_cart_style_one( $settings );
|
||||
break;
|
||||
case 'style-2':
|
||||
self::woo_cart_style_two( $settings );
|
||||
break;
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_after_cart' );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,833 @@
|
||||
<?php
|
||||
namespace Essential_Addons_Elementor\Template\Woocommerce\Checkout;
|
||||
|
||||
use \Elementor\Icons_Manager;
|
||||
use \Exception;
|
||||
use \Essential_Addons_Elementor\Classes\Helper as CheckoutHelperCLass;
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
trait Woo_Checkout_Helper {
|
||||
|
||||
public static $setting_data = [];
|
||||
|
||||
|
||||
public static function ea_get_woo_checkout_settings(){
|
||||
return self::$setting_data;
|
||||
}
|
||||
|
||||
public static function ea_set_woo_checkout_settings($setting){
|
||||
self::$setting_data = $setting;
|
||||
}
|
||||
/**
|
||||
* Show the checkout.
|
||||
*/
|
||||
public static function ea_checkout($settings) {
|
||||
// Show non-cart errors.
|
||||
do_action( 'woocommerce_before_checkout_form_cart_notices' );
|
||||
|
||||
// Check cart has contents.
|
||||
if ( WC()->cart->is_empty() && ! is_customize_preview() && apply_filters( 'woocommerce_checkout_redirect_empty_cart', true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check cart contents for errors.
|
||||
do_action( 'woocommerce_check_cart_items' );
|
||||
|
||||
// Calc totals.
|
||||
WC()->cart->calculate_totals();
|
||||
|
||||
// Get checkout object.
|
||||
$checkout = WC()->checkout();
|
||||
|
||||
if ( empty( $_POST ) && wc_notice_count( 'error' ) > 0 ) { // WPCS: input var ok, CSRF ok.
|
||||
|
||||
wc_get_template( 'checkout/cart-errors.php', array( 'checkout' => $checkout ) );
|
||||
wc_clear_notices();
|
||||
|
||||
} else {
|
||||
|
||||
$non_js_checkout = ! empty( $_POST['woocommerce_checkout_update_totals'] ); // WPCS: input var ok, CSRF ok.
|
||||
|
||||
if ( wc_notice_count( 'error' ) === 0 && $non_js_checkout ) {
|
||||
wc_add_notice( __( 'The order totals have been updated. Please confirm your order by pressing the "Place order" button at the bottom of the page.', 'essential-addons-for-elementor-lite' ) );
|
||||
}
|
||||
|
||||
if($settings['ea_woo_checkout_layout'] == 'default'){
|
||||
echo self::render_default_template_($checkout, $settings);
|
||||
}else {
|
||||
do_action('eael_add_woo_checkout_pro_layout', $checkout, $settings);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Order Received page.
|
||||
*/
|
||||
public static function ea_order_received( $order_id = 0 ) {
|
||||
$order = false;
|
||||
|
||||
// Get the order.
|
||||
$order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $order_id ) );
|
||||
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( wp_unslash( $_GET['key'] ) ) ); // WPCS: input var ok, CSRF ok.
|
||||
|
||||
if ( $order_id > 0 ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
if ( ! $order || ! hash_equals( $order->get_order_key(), $order_key ) ) {
|
||||
$order = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Empty awaiting payment session.
|
||||
unset( WC()->session->order_awaiting_payment );
|
||||
|
||||
// In case order is created from admin, but paid by the actual customer, store the ip address of the payer
|
||||
// when they visit the payment confirmation page.
|
||||
if ( $order && $order->is_created_via( 'admin' ) ) {
|
||||
$order->set_customer_ip_address( \WC_Geolocation::get_ip_address() );
|
||||
$order->save();
|
||||
}
|
||||
|
||||
// Empty current cart.
|
||||
wc_empty_cart();
|
||||
|
||||
wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the pay page.
|
||||
*/
|
||||
public static function ea_order_pay( $order_id ) {
|
||||
|
||||
do_action( 'before_woocommerce_pay' );
|
||||
|
||||
$order_id = absint( $order_id );
|
||||
|
||||
// Pay for existing order.
|
||||
if ( isset( $_GET['pay_for_order'], $_GET['key'] ) && $order_id ) { // WPCS: input var ok, CSRF ok.
|
||||
try {
|
||||
$order_key = isset( $_GET['key'] ) ? wc_clean( wp_unslash( $_GET['key'] ) ) : ''; // WPCS: input var ok, CSRF ok.
|
||||
$order = wc_get_order( $order_id );
|
||||
$hold_stock_minutes = (int) get_option( 'woocommerce_hold_stock_minutes', 0 );
|
||||
|
||||
// Order or payment link is invalid.
|
||||
if ( ! $order || $order->get_id() !== $order_id || ! hash_equals( $order->get_order_key(), $order_key ) ) {
|
||||
throw new Exception( __( 'Sorry, this order is invalid and cannot be paid for.', 'essential-addons-for-elementor-lite' ) );
|
||||
}
|
||||
|
||||
// Logged out customer does not have permission to pay for this order.
|
||||
if ( ! current_user_can( 'pay_for_order', $order_id ) && ! is_user_logged_in() ) {
|
||||
echo '<div class="woocommerce-info">' . esc_html__( 'Please log in to your account below to continue to the payment form.', 'essential-addons-for-elementor-lite' ) . '</div>';
|
||||
woocommerce_login_form(
|
||||
array(
|
||||
'redirect' => $order->get_checkout_payment_url(),
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add notice if logged in customer is trying to pay for guest order.
|
||||
if ( ! $order->get_user_id() && is_user_logged_in() ) {
|
||||
// If order has does not have same billing email then current logged in user then show warning.
|
||||
if ( $order->get_billing_email() !== wp_get_current_user()->user_email ) {
|
||||
wc_print_notice( __( 'You are paying for a guest order. Please continue with payment only if you recognize this order.', 'essential-addons-for-elementor-lite' ), 'error' );
|
||||
}
|
||||
}
|
||||
|
||||
// Logged in customer trying to pay for someone else's order.
|
||||
if ( ! current_user_can( 'pay_for_order', $order_id ) ) {
|
||||
throw new Exception( __( 'This order cannot be paid for. Please contact us if you need assistance.', 'essential-addons-for-elementor-lite' ) );
|
||||
}
|
||||
|
||||
// Does not need payment.
|
||||
if ( ! $order->needs_payment() ) {
|
||||
/* translators: %s: order status */
|
||||
throw new Exception( sprintf( __( 'This order’s status is “%s”—it cannot be paid for. Please contact us if you need assistance.', 'essential-addons-for-elementor-lite' ), wc_get_order_status_name( $order->get_status() ) ) );
|
||||
}
|
||||
|
||||
// Ensure order items are still stocked if paying for a failed order. Pending orders do not need this check because stock is held.
|
||||
if ( ! $order->has_status( wc_get_is_pending_statuses() ) ) {
|
||||
$quantities = array();
|
||||
|
||||
foreach ( $order->get_items() as $item_key => $item ) {
|
||||
if ( $item && is_callable( array( $item, 'get_product' ) ) ) {
|
||||
$product = $item->get_product();
|
||||
|
||||
if ( ! $product ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$quantities[ $product->get_stock_managed_by_id() ] = isset( $quantities[ $product->get_stock_managed_by_id() ] ) ? $quantities[ $product->get_stock_managed_by_id() ] + $item->get_quantity() : $item->get_quantity();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $order->get_items() as $item_key => $item ) {
|
||||
if ( $item && is_callable( array( $item, 'get_product' ) ) ) {
|
||||
$product = $item->get_product();
|
||||
|
||||
if ( ! $product ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! apply_filters( 'woocommerce_pay_order_product_in_stock', $product->is_in_stock(), $product, $order ) ) {
|
||||
/* translators: %s: product name */
|
||||
throw new Exception( sprintf( __( 'Sorry, "%s" is no longer in stock so this order cannot be paid for. We apologize for any inconvenience caused.', 'essential-addons-for-elementor-lite' ), $product->get_name() ) );
|
||||
}
|
||||
|
||||
// We only need to check products managing stock, with a limited stock qty.
|
||||
if ( ! $product->managing_stock() || $product->backorders_allowed() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check stock based on all items in the cart and consider any held stock within pending orders.
|
||||
$held_stock = ( $hold_stock_minutes > 0 ) ? wc_get_held_stock_quantity( $product, $order->get_id() ) : 0;
|
||||
$required_stock = $quantities[ $product->get_stock_managed_by_id() ];
|
||||
|
||||
if ( ! apply_filters( 'woocommerce_pay_order_product_has_enough_stock', ( $product->get_stock_quantity() >= ( $held_stock + $required_stock ) ), $product, $order ) ) {
|
||||
/* translators: 1: product name 2: quantity in stock */
|
||||
throw new Exception( sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s available). We apologize for any inconvenience caused.', 'essential-addons-for-elementor-lite' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity() - $held_stock, $product ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WC()->customer->set_props(
|
||||
array(
|
||||
'billing_country' => $order->get_billing_country() ? $order->get_billing_country() : null,
|
||||
'billing_state' => $order->get_billing_state() ? $order->get_billing_state() : null,
|
||||
'billing_postcode' => $order->get_billing_postcode() ? $order->get_billing_postcode() : null,
|
||||
)
|
||||
);
|
||||
WC()->customer->save();
|
||||
|
||||
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
|
||||
|
||||
if ( count( $available_gateways ) ) {
|
||||
current( $available_gateways )->set_current();
|
||||
}
|
||||
|
||||
wc_get_template(
|
||||
'checkout/form-pay.php',
|
||||
array(
|
||||
'order' => $order,
|
||||
'available_gateways' => $available_gateways,
|
||||
'order_button_text' => apply_filters( 'woocommerce_pay_order_button_text', __( 'Pay for order', 'essential-addons-for-elementor-lite' ) ),
|
||||
)
|
||||
);
|
||||
|
||||
} catch ( Exception $e ) {
|
||||
wc_print_notice( $e->getMessage(), 'error' );
|
||||
}
|
||||
} elseif ( $order_id ) {
|
||||
|
||||
// Pay for order after checkout step.
|
||||
$order_key = isset( $_GET['key'] ) ? wc_clean( wp_unslash( $_GET['key'] ) ) : ''; // WPCS: input var ok, CSRF ok.
|
||||
$order = wc_get_order( $order_id );
|
||||
|
||||
if ( $order && $order->get_id() === $order_id && hash_equals( $order->get_order_key(), $order_key ) ) {
|
||||
|
||||
if ( $order->needs_payment() ) {
|
||||
|
||||
wc_get_template( 'checkout/order-receipt.php', array( 'order' => $order ) );
|
||||
|
||||
} else {
|
||||
/* translators: %s: order status */
|
||||
wc_print_notice( sprintf( __( 'This order’s status is “%s”—it cannot be paid for. Please contact us if you need assistance.', 'essential-addons-for-elementor-lite' ), wc_get_order_status_name( $order->get_status() ) ), 'error' );
|
||||
}
|
||||
} else {
|
||||
wc_print_notice( __( 'Sorry, this order is invalid and cannot be paid for.', 'essential-addons-for-elementor-lite' ), 'error' );
|
||||
}
|
||||
} else {
|
||||
wc_print_notice( __( 'Invalid order.', 'essential-addons-for-elementor-lite' ), 'error' );
|
||||
}
|
||||
|
||||
do_action( 'after_woocommerce_pay' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the coupon.
|
||||
*/
|
||||
public static function ea_coupon_template() {
|
||||
$settings = self::ea_get_woo_checkout_settings();
|
||||
if ( get_option( 'woocommerce_enable_coupons' ) === 'no' || $settings['ea_woo_checkout_coupon_hide'] === 'yes' ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="woo-checkout-coupon">
|
||||
<?php if( wc_coupons_enabled() ) { ?>
|
||||
<div class="woocommerce-form-coupon-toggle">
|
||||
<div class="ea-coupon-icon">
|
||||
<?php Icons_Manager::render_icon( $settings['ea_woo_checkout_coupon_icon'], [ 'aria-hidden' => 'true' ] ); ?>
|
||||
</div>
|
||||
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_coupon_message', $settings['ea_woo_checkout_coupon_title'] . ' <a href="#" class="showcoupon">' . $settings['ea_woo_checkout_coupon_link_text'] . '</a>' ), 'notice' ); ?>
|
||||
</div>
|
||||
|
||||
<form class="checkout_coupon woocommerce-form-coupon" method="post" style="display:none">
|
||||
|
||||
<p><?php esc_html_e( $settings['ea_woo_checkout_coupon_form_content'], 'essential-addons-for-elementor-lite' ); ?></p>
|
||||
|
||||
<p class="form-row form-row-first">
|
||||
<input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( $settings['ea_woo_checkout_coupon_placeholder_text'], 'essential-addons-for-elementor-lite' ); ?>" id="coupon_code" value="" />
|
||||
</p>
|
||||
|
||||
<p class="form-row form-row-last">
|
||||
<button type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( $settings['ea_woo_checkout_coupon_button_text'], 'essential-addons-for-elementor-lite' ); ?>"><?php esc_html_e( $settings['ea_woo_checkout_coupon_button_text'], 'essential-addons-for-elementor-lite' ); ?></button>
|
||||
</p>
|
||||
|
||||
<div class="clear"></div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php }
|
||||
|
||||
/**
|
||||
* Show the login.
|
||||
*/
|
||||
public static function ea_login_template(){
|
||||
$settings = self::ea_get_woo_checkout_settings();
|
||||
$class = '';
|
||||
$status = true;
|
||||
if('no' === get_option( 'woocommerce_enable_checkout_login_reminder')){
|
||||
return '';
|
||||
}elseif(\Elementor\Plugin::$instance->editor->is_edit_mode() && 'yes' === $settings['ea_section_woo_login_show']){
|
||||
$class = 'woo-checkout-login-editor';
|
||||
}elseif(!is_user_logged_in()){
|
||||
$class = 'eael-woo-checkout-login-page';
|
||||
}else{
|
||||
return '';
|
||||
}
|
||||
ob_start();
|
||||
?>
|
||||
<div class="woo-checkout-login <?php echo $class; ?>">
|
||||
<div class="woocommerce-form-login-toggle">
|
||||
<div class="ea-login-icon">
|
||||
<?php Icons_Manager::render_icon( $settings['ea_woo_checkout_login_icon'], [ 'aria-hidden' => 'true' ] ); ?>
|
||||
</div>
|
||||
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_login_message', $settings['ea_woo_checkout_login_title'] ) . ' <a href="#" class="showlogin">' . $settings['ea_woo_checkout_login_link_text'] . '</a>', 'notice' ); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$message = CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_login_message']);
|
||||
|
||||
$redirect = wc_get_checkout_url();
|
||||
$hidden = true;
|
||||
?>
|
||||
<form class="woocommerce-form woocommerce-form-login login" method="post" <?php echo ( $hidden ) ? 'style="display:none;"' : ''; ?>>
|
||||
|
||||
<?php do_action( 'woocommerce_login_form_start' ); ?>
|
||||
|
||||
<?php echo ( $message ) ? wpautop( wptexturize( $message ) ) : ''; // @codingStandardsIgnoreLine ?>
|
||||
|
||||
<p class="form-row form-row-first">
|
||||
<label for="username"><?php esc_html_e( 'Username or email', 'essential-addons-for-elementor-lite' ); ?> <span class="required">*</span></label>
|
||||
<input type="text" class="input-text" name="username" id="username" autocomplete="username" />
|
||||
</p>
|
||||
<p class="form-row form-row-last">
|
||||
<label for="password"><?php esc_html_e( 'Password', 'essential-addons-for-elementor-lite' ); ?> <span class="required">*</span></label>
|
||||
<input class="input-text" type="password" name="password" id="password" autocomplete="current-password" />
|
||||
</p>
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php do_action( 'woocommerce_login_form' ); ?>
|
||||
|
||||
<p class="form-row">
|
||||
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox woocommerce-form-login__rememberme">
|
||||
<input class="woocommerce-form__input woocommerce-form__input-checkbox" name="rememberme" type="checkbox" id="rememberme" value="forever" /> <span><?php esc_html_e( 'Remember me', 'essential-addons-for-elementor-lite' ); ?></span>
|
||||
</label>
|
||||
<?php wp_nonce_field( 'woocommerce-login', 'woocommerce-login-nonce' ); ?>
|
||||
<input type="hidden" name="redirect" value="<?php echo esc_url( $redirect ); ?>" />
|
||||
<button type="submit" class="woocommerce-button button woocommerce-form-login__submit" name="login" value="<?php esc_attr_e( 'Login', 'essential-addons-for-elementor-lite' ); ?>"><?php esc_html_e( 'Login', 'essential-addons-for-elementor-lite' ); ?></button>
|
||||
</p>
|
||||
<p class="lost_password">
|
||||
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php esc_html_e( 'Lost your password?', 'essential-addons-for-elementor-lite' ); ?></a>
|
||||
</p>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php do_action( 'woocommerce_login_form_end' ); ?>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
$content = ob_get_clean();
|
||||
if($status){
|
||||
echo $content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the login.
|
||||
*/
|
||||
public static function checkout_order_review_template() {
|
||||
$settings = self::ea_get_woo_checkout_settings();
|
||||
?>
|
||||
<?php do_action('woocommerce_checkout_before_order_review_heading'); ?>
|
||||
<h2 id="order_review_heading" class="woo-checkout-section-title">
|
||||
<?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_order_details_title']); ?>
|
||||
</h2>
|
||||
|
||||
<?php do_action('woocommerce_checkout_before_order_review'); ?>
|
||||
|
||||
<div class="ea-woo-checkout-order-review">
|
||||
<?php self::checkout_order_review_default($settings); ?>
|
||||
</div>
|
||||
|
||||
<?php do_action('woocommerce_checkout_after_order_review'); ?>
|
||||
<?php }
|
||||
|
||||
public function remove_woocommerce_display_recurring_totals( $settings ){
|
||||
remove_action('woocommerce_review_order_after_order_total', array( 'WC_Subscriptions_Cart', 'display_recurring_totals' ), 10);
|
||||
}
|
||||
/**
|
||||
* Show the order review.
|
||||
*/
|
||||
public static function checkout_order_review_default($settings) {
|
||||
WC()->cart->calculate_totals();
|
||||
?>
|
||||
|
||||
<div class="ea-checkout-review-order-table">
|
||||
<ul class="ea-order-review-table">
|
||||
<?php
|
||||
if( $settings['ea_woo_checkout_layout'] == 'default' ) { ?>
|
||||
<li class="table-header">
|
||||
<div class="table-col-1"><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_product_text']); ?></div>
|
||||
<div class="table-col-2"><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_quantity_text']); ?></div>
|
||||
<div class="table-col-3"><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_price_text']); ?></div>
|
||||
</li>
|
||||
<?php }
|
||||
?>
|
||||
|
||||
<?php
|
||||
do_action( 'woocommerce_review_order_before_cart_contents' );
|
||||
|
||||
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
||||
|
||||
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
|
||||
?>
|
||||
<li class="table-row <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
|
||||
<div class="table-col-1 product-thum-name">
|
||||
<div class="product-thumbnail">
|
||||
<?php
|
||||
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
|
||||
echo $thumbnail; // PHPCS: XSS ok.
|
||||
?>
|
||||
</div>
|
||||
<div class="product-name">
|
||||
<?php $name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo CheckoutHelperCLass::eael_wp_kses( $name );
|
||||
?>
|
||||
<?php if( $settings['ea_woo_checkout_layout'] == 'split' || $settings['ea_woo_checkout_layout'] == 'multi-steps' ) {
|
||||
if( !empty( $settings['ea_woo_checkout_cart_update_enable'] ) && 'yes' === $settings['ea_woo_checkout_cart_update_enable'] ) {
|
||||
static::eael_checkout_cart_quantity_input_print( $_product, $cart_item_key, $cart_item );
|
||||
}else {
|
||||
echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key );
|
||||
}
|
||||
} // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if( $settings['ea_woo_checkout_layout'] == 'default' ) { ?>
|
||||
<div class="table-col-2 product-quantity">
|
||||
<?php
|
||||
if( !empty( $settings['ea_woo_checkout_cart_update_enable'] ) && 'yes' === $settings['ea_woo_checkout_cart_update_enable'] ) {
|
||||
static::eael_checkout_cart_quantity_input_print( $_product, $cart_item_key, $cart_item );
|
||||
} else {
|
||||
echo apply_filters( 'woocommerce_checkout_cart_item_quantity', $cart_item['quantity'], $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="table-col-3 product-total eael-checkout-cart-item-total">
|
||||
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_review_order_after_cart_contents' );
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<div class="ea-order-review-table-footer">
|
||||
<!-- Show default text (from woocommerce) if change label control (ea_woo_checkout_table_header_text) is off -->
|
||||
<?php $woo_checkout_order_details_change_label_settings = !empty($settings['ea_woo_checkout_table_header_text']) ? CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_header_text']) : ''; ?>
|
||||
|
||||
<?php
|
||||
if($settings['ea_woo_checkout_shop_link'] == 'yes') { ?>
|
||||
<div class="back-to-shop">
|
||||
<a class="back-to-shopping" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
|
||||
<?php //if($woo_checkout_order_details_change_label_settings == 'yes') : ?>
|
||||
<!-- <i class="fas fa-long-arrow-alt-left"></i>--><?php //echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_shop_link_text']); ?>
|
||||
<?php //else : ?>
|
||||
<!-- <i class="fas fa-long-arrow-alt-left"></i>--><?php //esc_html_e( 'Continue Shopping', 'essential-addons-for-elementor-lite' ); ?>
|
||||
<?php //endif; ?>
|
||||
<i class="fas fa-long-arrow-alt-left"></i><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_shop_link_text']); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="footer-content">
|
||||
<div class="cart-subtotal">
|
||||
<?php if($woo_checkout_order_details_change_label_settings == 'yes') : ?>
|
||||
<div><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_subtotal_text']); ?></div>
|
||||
<?php else : ?>
|
||||
<?php esc_html_e( 'Subtotal', 'essential-addons-for-elementor-lite' ); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="eael-checkout-cart-subtotal"><?php wc_cart_totals_subtotal_html(); ?></div>
|
||||
</div>
|
||||
|
||||
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
|
||||
<div class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
|
||||
<div><?php wc_cart_totals_coupon_label( $coupon ); ?></div>
|
||||
<div><?php wc_cart_totals_coupon_html( $coupon ); ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
|
||||
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
|
||||
<div class="shipping-area">
|
||||
<?php
|
||||
wc_cart_totals_shipping_html();
|
||||
?>
|
||||
</div>
|
||||
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action('eael_woo_checkout_before_cart_get_fees', WC()); ?>
|
||||
|
||||
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
|
||||
<?php apply_filters('eael_woo_checkout_cart_fee', $fee); ?>
|
||||
<div class="fee">
|
||||
<div><?php echo esc_html( $fee->name ); ?></div>
|
||||
<div><?php wc_cart_totals_fee_html( $fee ); ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
|
||||
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
|
||||
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited ?>
|
||||
<div class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
|
||||
<div><?php echo esc_html( $tax->label ); ?></div>
|
||||
<div><?php echo wp_kses_post( $tax->formatted_amount ); ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<div class="tax-total">
|
||||
<div><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></div>
|
||||
<div><?php wc_cart_totals_taxes_total_html(); ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
|
||||
|
||||
<div class="order-total">
|
||||
<?php if($woo_checkout_order_details_change_label_settings == 'yes') : ?>
|
||||
<div><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_total_text']); ?></div>
|
||||
<?php else : ?>
|
||||
<?php esc_html_e( 'Total', 'essential-addons-for-elementor-lite' ); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="eael-checkout-cart-total"><?php wc_cart_totals_order_total_html(); ?></div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if( class_exists('WC_Subscriptions_Cart') && (\WC_Subscriptions_Cart::cart_contains_subscription())) {
|
||||
echo '<table class="recurring-wrapper">';
|
||||
do_action( 'eael_display_recurring_total_total' );
|
||||
echo '</table>';
|
||||
}
|
||||
?>
|
||||
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the default layout.
|
||||
*/
|
||||
public static function render_default_template_($checkout, $settings) {
|
||||
?>
|
||||
<?php
|
||||
// If checkout registration is disabled and not logged in, the user cannot checkout.
|
||||
if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in() ) {
|
||||
echo esc_html( apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'essential-addons-for-elementor-lite' ) ) );
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<?php do_action( 'woocommerce_before_checkout_form', $checkout ); ?>
|
||||
|
||||
<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
|
||||
|
||||
<?php if ( $checkout->get_checkout_fields() ) : ?>
|
||||
|
||||
<?php do_action( 'woocommerce_checkout_before_customer_details' ); ?>
|
||||
|
||||
<div class="col2-set" id="customer_details">
|
||||
<div class="col-1">
|
||||
<?php do_action( 'woocommerce_checkout_billing' ); ?>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<?php do_action( 'woocommerce_checkout_shipping' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_checkout_order_review' ); ?>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
do_action('woocommerce_after_checkout_form', $checkout);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the billing form.
|
||||
*/
|
||||
public function ea_checkout_form_billing() {
|
||||
// Get checkout object.
|
||||
$checkout = WC()->checkout();
|
||||
$settings = self::ea_get_woo_checkout_settings();
|
||||
?>
|
||||
<div class="woocommerce-billing-fields">
|
||||
<?php if ( wc_ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>
|
||||
|
||||
<h3><?php esc_html_e( 'Billing & Shipping', 'essential-addons-for-elementor-lite' ); ?></h3>
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<h3><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_billing_title']); ?></h3>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_before_checkout_billing_form', $checkout ); ?>
|
||||
|
||||
<div class="woocommerce-billing-fields__field-wrapper">
|
||||
<?php
|
||||
$fields = $checkout->get_checkout_fields( 'billing' );
|
||||
|
||||
foreach ( $fields as $key => $field ) {
|
||||
woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_after_checkout_billing_form', $checkout ); ?>
|
||||
</div>
|
||||
|
||||
<?php if ( ! is_user_logged_in() && $checkout->is_registration_enabled() ) : ?>
|
||||
<div class="woocommerce-account-fields">
|
||||
<?php if ( ! $checkout->is_registration_required() ) : ?>
|
||||
|
||||
<p class="form-row form-row-wide create-account">
|
||||
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
|
||||
<input class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" id="createaccount" <?php checked( ( true === $checkout->get_value( 'createaccount' ) || ( true === apply_filters( 'woocommerce_create_account_default_checked', false ) ) ), true ); ?> type="checkbox" name="createaccount" value="1" /> <span><?php esc_html_e( 'Create an account?', 'essential-addons-for-elementor-lite' ); ?></span>
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_before_checkout_registration_form', $checkout ); ?>
|
||||
|
||||
<?php if ( $checkout->get_checkout_fields( 'account' ) ) : ?>
|
||||
|
||||
<div class="create-account">
|
||||
<?php foreach ( $checkout->get_checkout_fields( 'account' ) as $key => $field ) : ?>
|
||||
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
|
||||
<?php endforeach; ?>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_after_checkout_registration_form', $checkout ); ?>
|
||||
</div>
|
||||
<?php endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the shipping form.
|
||||
*/
|
||||
public function ea_checkout_form_shipping() {
|
||||
// Get checkout object.
|
||||
$checkout = WC()->checkout();
|
||||
$settings = self::ea_get_woo_checkout_settings();
|
||||
?>
|
||||
<div class="woocommerce-shipping-fields">
|
||||
<?php if ( true === WC()->cart->needs_shipping_address() ) : ?>
|
||||
|
||||
<h3 id="ship-to-different-address">
|
||||
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
|
||||
<input id="ship-to-different-address-checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" <?php checked( apply_filters( 'woocommerce_ship_to_different_address_checked', 'shipping' === get_option( 'woocommerce_ship_to_destination' ) ? 1 : 0 ), 1 ); ?> type="checkbox" name="ship_to_different_address" value="1" /> <span><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_shipping_title']); ?></span>
|
||||
</label>
|
||||
</h3>
|
||||
|
||||
<div class="shipping_address">
|
||||
|
||||
<?php do_action( 'woocommerce_before_checkout_shipping_form', $checkout ); ?>
|
||||
|
||||
<div class="woocommerce-shipping-fields__field-wrapper">
|
||||
<?php
|
||||
$fields = $checkout->get_checkout_fields( 'shipping' );
|
||||
|
||||
foreach ( $fields as $key => $field ) {
|
||||
woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_after_checkout_shipping_form', $checkout ); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="woocommerce-additional-fields">
|
||||
<?php do_action( 'woocommerce_before_order_notes', $checkout ); ?>
|
||||
|
||||
<?php if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' === get_option( 'woocommerce_enable_order_comments', 'yes' ) ) ) : ?>
|
||||
|
||||
<?php if ( ! WC()->cart->needs_shipping() || wc_ship_to_billing_address_only() ) : ?>
|
||||
|
||||
<h3><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_additional_info_title']); ?></h3>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="woocommerce-additional-fields__field-wrapper">
|
||||
<?php foreach ( $checkout->get_checkout_fields( 'order' ) as $key => $field ) : ?>
|
||||
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_after_order_notes', $checkout ); ?>
|
||||
</div>
|
||||
<?php }
|
||||
|
||||
/**
|
||||
* Output the payment.
|
||||
*/
|
||||
public function ea_checkout_payment() {
|
||||
if ( WC()->cart->needs_payment() ) {
|
||||
$available_gateways = WC()->payment_gateways()->get_available_payment_gateways();
|
||||
WC()->payment_gateways()->set_current_gateway( $available_gateways );
|
||||
} else {
|
||||
$available_gateways = array();
|
||||
}
|
||||
|
||||
$settings = self::ea_get_woo_checkout_settings();
|
||||
?>
|
||||
|
||||
<div class="woo-checkout-payment">
|
||||
<?php do_action('eael_wc_multistep_checkout_after_shipping'); ?>
|
||||
<h3 id="payment-title" class="woo-checkout-section-title">
|
||||
<?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_payment_title']); ?>
|
||||
</h3>
|
||||
|
||||
<?php wc_get_template(
|
||||
'checkout/payment.php',
|
||||
array(
|
||||
'checkout' => WC()->checkout(),
|
||||
'available_gateways' => $available_gateways,
|
||||
'order_button_text' => apply_filters( 'woocommerce_order_button_text', CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_place_order_text']) ),
|
||||
)
|
||||
); ?>
|
||||
</div>
|
||||
<?php }
|
||||
|
||||
public function custom_shipping_package_name( $name ) {
|
||||
if( ! empty( self::$setting_data[ 'ea_woo_checkout_table_shipping_text' ] ) ) {
|
||||
$name = self::$setting_data['ea_woo_checkout_table_shipping_text'];
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Added all actions
|
||||
*/
|
||||
public function ea_woo_checkout_add_actions($settings) {
|
||||
|
||||
self::ea_set_woo_checkout_settings($settings);
|
||||
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
|
||||
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
|
||||
if(!did_action('woocommerce_before_checkout_form')){
|
||||
add_action( 'woocommerce_before_checkout_form', [ $this, 'ea_login_template' ], 10 );
|
||||
add_action( 'woocommerce_before_checkout_form', [ $this, 'ea_coupon_template' ], 10 );
|
||||
}
|
||||
|
||||
if( $settings['ea_woo_checkout_layout'] == 'default' ) {
|
||||
if(!did_action('woocommerce_before_checkout_form')){
|
||||
add_action( 'woocommerce_before_checkout_form', [ $this, 'checkout_order_review_template' ], 9 );
|
||||
}
|
||||
}
|
||||
|
||||
$wc_checkout_instance = WC()->checkout();
|
||||
remove_action( 'woocommerce_checkout_billing', [ $wc_checkout_instance, 'checkout_form_billing' ] );
|
||||
remove_action( 'woocommerce_checkout_shipping', [ $wc_checkout_instance, 'checkout_form_shipping' ] );
|
||||
|
||||
if(!did_action('woocommerce_checkout_billing')){
|
||||
add_action( 'woocommerce_checkout_billing', [ $this, 'ea_checkout_form_billing' ], 10);
|
||||
}
|
||||
|
||||
if(!did_action('woocommerce_checkout_shipping')){
|
||||
add_action( 'woocommerce_checkout_shipping', [ $this, 'ea_checkout_form_shipping' ], 10 );
|
||||
}
|
||||
|
||||
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
|
||||
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
|
||||
if(!did_action('woocommerce_checkout_order_review')){
|
||||
add_action( 'woocommerce_checkout_order_review', [ $this, 'ea_checkout_payment' ], 20 );
|
||||
}
|
||||
|
||||
remove_action('woocommerce_checkout_billing', [ $wc_checkout_instance, 'checkout_form_shipping' ]);
|
||||
add_filter('woocommerce_shipping_package_name', [ $this, 'custom_shipping_package_name' ], 10, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print quantity input field
|
||||
* @return void
|
||||
*
|
||||
* @since 5.1.4
|
||||
*/
|
||||
public static function eael_checkout_cart_quantity_input_print($_product, $cart_item_key, $cart_item){
|
||||
|
||||
if ( $_product->is_sold_individually() ) {
|
||||
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
|
||||
} else {
|
||||
$product_quantity = woocommerce_quantity_input(
|
||||
[
|
||||
'input_name' => "cart[{$cart_item_key}][qty]",
|
||||
'input_value' => $cart_item['quantity'],
|
||||
'max_value' => $_product->get_max_purchase_quantity(),
|
||||
'min_value' => '0',
|
||||
'product_name' => $_product->get_name(),
|
||||
'classes' => array('eael-checkout-cart-qty-input', 'input-text', 'qty', 'text'),
|
||||
],
|
||||
$_product,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity,
|
||||
$cart_item_key, $cart_item ); // PHPCS: XSS ok.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user