Skip to content

Instantly share code, notes, and snippets.

@encoderit-arman
Created November 19, 2020 06:02
Show Gist options
  • Select an option

  • Save encoderit-arman/5e211e878e675ed65fc57da333634910 to your computer and use it in GitHub Desktop.

Select an option

Save encoderit-arman/5e211e878e675ed65fc57da333634910 to your computer and use it in GitHub Desktop.
<span class="count total-qty-count"><?php echo $woocommerce->cart->cart_contents_count; ?></span>
<div class="shopping-cart">
<ul class="shopping-cart-items" id="list-item">
<?php
foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
$product = $cart_item['data'];
$product_id = $cart_item['product_id'];
$quantity = $cart_item['quantity'];
$price = WC()->cart->get_product_price($product);
$subtotal = WC()->cart->get_product_subtotal($product, $cart_item['quantity']);
$link = $product->get_permalink($cart_item);
// Anything related to $product, check $product tutorial
$meta = wc_get_formatted_cart_item_data($cart_item);
// var_dump($product);
$product_name = $product->name;
$product_image = $product->get_image();
?>
<li class="clearfix " id="remove-product<?php echo $product_id;?>">
<div class="item-details">
<span>
<a class="delete-item btn " data-productid="<?php echo $product_id; ?>">
<i class="fas fa-times-circle"></i>
</a>
</span>
<span class="item-name"><?php echo $product_name; ?></span>
<div class="dd">
<?php echo $quantity; ?>
x <span><?php echo $price; ?></span>
</div>
</div>
<a href="<?php echo $link; ?>"><?php echo $product_image; ?></a>
</li>
<?php
}
?>
</ul>
</div>
<p class="total d-flex justify-content-between">
<span class="label">Total:</span>
<span class="price">
<span class="total-price">
<?php
echo $woocommerce->cart->get_cart_total()
?>
</span>
</span>
</p>
<div class="modal-footer justify-content-between">
<a href="#" class="btn btn-cart">View cart</a>
<a href="#" class="btn btn-cheakout">Checkout</a>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment