154 lines
9.1 KiB
PHP
154 lines
9.1 KiB
PHP
<?php
|
|
/**
|
|
* Mini-cart
|
|
*
|
|
* @author Md Obaid Rahman
|
|
* @package astra/WooCommerce
|
|
* @version 5.2.0
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) :
|
|
exit; // Exit if accessed directly
|
|
endif;
|
|
|
|
do_action('woocommerce_before_mini_cart');
|
|
|
|
if (!WC()->cart->is_empty()) :
|
|
$cart_items = WC()->cart->get_cart();
|
|
?>
|
|
<div class="softoba-minicart-items">
|
|
<div class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr($args['list_class']); ?>">
|
|
<?php
|
|
do_action('woocommerce_before_mini_cart_contents');
|
|
|
|
foreach ($cart_items 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_widget_cart_item_visible', true, $cart_item, $cart_item_key)) :
|
|
$product_name = apply_filters('woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key);
|
|
$thumbnail = apply_filters('woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key);
|
|
$product_price = apply_filters('woocommerce_cart_item_price', WC()->cart->get_product_price($_product), $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="softoba_single_cart_item softoba-flex align-start mini-cart-item woocommerce-mini-cart-item <?php echo esc_attr(apply_filters('woocommerce_mini_cart_item_class', 'mini_cart_item', $cart_item, $cart_item_key)); ?>">
|
|
<div class="softoba-image-cart-item">
|
|
<?php echo $thumbnail; ?>
|
|
<?php echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
'woocommerce_cart_item_remove_link',
|
|
sprintf(
|
|
'<a href="%s" class="remove remove_from_cart_button remove-from-cart-btn" aria-label="%s" data-product_id="%s" data-cart_item_key="%s" data-product_sku="%s" data-type="clean_cart_item" data-source="mini_cart_remove">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
|
|
<path data-name="Path 16584" d="M17.074,2.925a10,10,0,1,0,0,14.149A10.016,10.016,0,0,0,17.074,2.925Zm-3.129,11.02a.769.769,0,0,1-1.088,0L10,11.088,7.007,14.081a.769.769,0,0,1-1.088-1.088L8.912,10,6.055,7.143A.769.769,0,0,1,7.143,6.055L10,8.912l2.721-2.721a.769.769,0,0,1,1.088,1.088L11.088,10l2.857,2.857A.769.769,0,0,1,13.945,13.945Z" transform="translate(0 0)" fill="#fff"/>
|
|
</svg>
|
|
</a>',
|
|
esc_url(wc_get_cart_remove_url($cart_item_key)),
|
|
esc_attr__('Remove this item', 'astra'),
|
|
esc_attr($product_id),
|
|
esc_attr($cart_item_key),
|
|
esc_attr($_product->get_sku())
|
|
),
|
|
$cart_item_key
|
|
); ?>
|
|
</div>
|
|
|
|
<div class="softoba-info-cart-item padding-left-15 rtl-padding-left-0 rtl-padding-right-15">
|
|
<div class="mini-cart-info">
|
|
<div class="softoba-flex jbw align-start">
|
|
<?php if (empty($product_permalink)) : ?>
|
|
<span class="product-name softoba-bold"><?php echo $product_name; ?></span>
|
|
<?php else : ?>
|
|
<a class="product-name softoba-bold" href="<?php echo esc_url($product_permalink); ?>" title="<?php echo esc_attr($product_name); ?>">
|
|
<?php echo $product_name; ?>
|
|
</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php echo wc_get_formatted_cart_item_data($cart_item); ?>
|
|
|
|
<?php
|
|
if ($product_price) :
|
|
echo '<div class="softoba-flex jbw align-start mini-cart-item-price margin-top-10">';
|
|
|
|
$wrap = false;
|
|
$quantily_show = true;
|
|
// $quantily_show = false;
|
|
if ($_product->is_sold_individually()) :
|
|
$product_quantity = sprintf('<input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key);
|
|
else :
|
|
$wrap = true;
|
|
$product_quantity = woocommerce_quantity_input(
|
|
array(
|
|
'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_name
|
|
),
|
|
$_product,
|
|
false
|
|
);
|
|
endif;
|
|
echo $wrap ? '<div class="quantity-wrap softoba-flex flex-wrap">' : '';
|
|
echo apply_filters('woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item); // PHPCS: XSS ok.
|
|
|
|
echo apply_filters('woocommerce_widget_cart_item_quantity', '<div class="cart_list_product_quantity">' . ($quantily_show ? sprintf('%s × %s', $cart_item['quantity'], $product_price) : sprintf('× %s', $product_price)) . '</div>', $cart_item, $cart_item_key);
|
|
|
|
echo $wrap ? '</div>' : '';
|
|
|
|
/**
|
|
* Sub Total
|
|
*/
|
|
echo '<div class="mini-cart-item-subtotal softoba-bold margin-left-10 rtl-margin-left-0 rtl-margin-right-10">';
|
|
echo apply_filters('woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal($_product, $cart_item['quantity']), $cart_item, $cart_item_key);
|
|
echo '</div>';
|
|
|
|
echo '</div>';
|
|
endif;
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
endif;
|
|
endforeach;
|
|
|
|
do_action('woocommerce_mini_cart_contents');
|
|
?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="softoba-minicart-footer">
|
|
<div class="minicart_total_checkout woocommerce-mini-cart__total total">
|
|
<?php
|
|
/**
|
|
* Woocommerce_widget_shopping_cart_total hook.
|
|
*
|
|
* @removed woocommerce_widget_shopping_cart_subtotal - 10
|
|
* @hooked elessi_widget_shopping_cart_subtotal - 10
|
|
* @hooked elessi_subtotal_free_shipping - 15
|
|
*/
|
|
do_action('woocommerce_widget_shopping_cart_total');
|
|
?>
|
|
</div>
|
|
<div class="btn-mini-cart inline-lists text-center">
|
|
<?php do_action('woocommerce_widget_shopping_cart_before_buttons'); ?>
|
|
|
|
<p class="woocommerce-mini-cart__buttons buttons">
|
|
<?php do_action('woocommerce_widget_shopping_cart_buttons'); ?>
|
|
</p>
|
|
|
|
<?php do_action('woocommerce_widget_shopping_cart_after_buttons'); ?>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
/**
|
|
* Empty cart
|
|
*/
|
|
else :
|
|
echo '<p class="empty woocommerce-mini-cart__empty-message">' . esc_html__('No products in the cart.', 'astra') . '<a href="javascript:void(0);" class="button softoba-sidebar-return-shop" rel="nofollow">' . esc_html__('RETURN TO SHOP', 'astra') . '</a></p>';
|
|
endif;
|
|
|
|
do_action('woocommerce_after_mini_cart');
|
|
|