File: /var/www/dinamo-shop/wp-content/themes/dinamo-shop/woocommerce/cart/cart-content.php
<div class="empty-state-outter" style="display:none;" id="CartEmpty">
<div class="empty-state">
<div class="empty-icon">
<img src="<?= THEMEROOT ?>/assets/img/shopping-bag.png" />
</div>
<h2><?= __('Nema proizvoda', 'dinamo-shop'); ?></h2>
<p><?= __('U ovom trenutku nema proivoda u ovoj kategoriji. Pogledajte ostale kategorije lijevo u izborniku ili idite natrag na naslovnicu klikom na gumb niže.', 'dinamo-shop'); ?></p>
<a href="<?= get_home_url(); ?>" class="btn btn-primary" ><?= __('Idi na naslovnu', 'tokic_theme'); ?></a>
</div>
</div>
<?php
$has_secondary_currency = get_field('has_secondary_currency', 'options');
$active_currency = get_woocommerce_currency();
$has_null = false;
?>
<div id="MainCart">
<h2><?php _e('Vaša košarica', 'dinamo_shop'); ?></h2>
<form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
<?php do_action( 'woocommerce_before_cart_table' ); ?>
<table class="table-products">
<thead>
<tr>
<th><?php _e('Proizvod', 'dinamo_shop'); ?></th>
<th><?php _e('Cijena pojedinačno', 'dinamo_shop'); ?></th>
<th class="text-center"><?php _e('Količina', 'dinamo_shop'); ?></th>
<th><?php _e('Cijena ukupno', 'dinamo_shop'); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
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_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);
$product_price = $_product->regular_price;
$product_sale_price = $_product->sale_price;
$product_lowest_price = get_post_meta($product_id, '_lowest_price_30_days', true);
if($cart_item["variation"]["print_type"]){
$prod_var = wc_get_product($cart_item["variation_id"]);
if($prod_var->get_price() == 0){
$has_null = true;
}
}
if($_product->price == 0){
$has_null = true;
}
$product_permalink = apply_filters('woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink($cart_item) : '', $cart_item, $cart_item_key);
$print_type = $cart_item["variation"]["print_type"];
$print_product_id = get_product_for_print_type($print_type);
$print_name_value = "";
$print_number_value = "";
if($cart_item["variation"] && $cart_item["variation"]["print_name_value"]) {
$print_name_value = $cart_item["variation"]["print_name_value"];
}
if($cart_item["variation"] && $cart_item["variation"]["print_number_value"]) {
$print_number_value = $cart_item["variation"]["print_number_value"];
}
$print_name = get_print_name_for_print_type($print_type, $print_name_value, $print_number_value );
$europa_league_print_name = "";
if(isset($cart_item["variation"]["print_europa_league"]) && $cart_item["variation"]["print_europa_league"]) {
$europa_league_print_id = get_field('print_europa_league', 'option');
$europa_league_print_name = get_the_title($europa_league_print_id);
}
$europa_league = "0";
if(isset($cart_item["variation"]["print_europa_league"])) {
$europa_league = $cart_item["variation"]["print_europa_league"];
}
?>
<tr data-cart-item="<?= $cart_item_key ?>">
<td>
<div class="details">
<div>
<div class="details-img">
<?= $_product->get_image('product_thumbnail_small', array('class' => 'img-fluid lazyload')); ?>
</div>
<div class="form-group quantity small show-md">
<span data-cart-item-key="<?= $cart_item_key ?>" data-change-qt="down" data-product-id="<?= $product_id ?>" class="minus <?= ($cart_item['quantity'] == '1') ? 'minus--unclickable' : ''; ?>">-</span>
<input type="number" value="<?= $cart_item['quantity']; ?>" class="form-control" name="quantity">
<span data-cart-item-key="<?= $cart_item_key ?>" data-change-qt="up" data-product-id="<?= $product_id ?>" class="plus">+</span>
</div>
</div>
<div class="details-desc">
<div>
<?php $brands = get_the_terms( $product->id, 'dinamo_brands' ); ?>
<?php if( $brands ) : ?>
<h4 class="hide-sm"><?php echo $brands[0]->name; ?></h4>
<?php endif; ?>
<div class="d-flex flex-row">
<h3><?= $product_name; ?></h3>
<a class="margin-left-auto show-md"><svg class="icon icon-delete"><use xlink:href="<?php echo THEMEROOT; ?>/assets/icons/icons.svg#icon-delete"></use></svg></a>
</div>
<div class="d-flex flex-wrap">
<?php if($print_name){ ?>
<label style="font-size: 13px; color: #909090;"><?= $print_name ?></label>
<?php } ?>
</div>
<div class="d-flex flex-wrap">
<?php if($europa_league_print_name){ ?>
<label style="font-size: 13px; color: #909090;"><?= $europa_league_print_name ?></label>
<?php } ?>
</div>
<div class="d-flex align-items-center flex-wrap mt-5 show-md">
<?php if ($_product->is_on_sale()){ ?>
<h4 class="lowest-price"><?= __( 'Najniža cijena u zadnjih 30 dana: ', 'lowest-price' ) ?><span class="lowest_amount"><?= wc_price( $product_lowest_price ) . $_product->get_price_suffix() ?></span></h4>
<?php } ?>
<div class="d-flex flex-row justify-content-<?= $has_secondary_currency ? "between" : "end" ?> full-width">
<?php if ($has_secondary_currency) { ?>
<div class="d-flex flex-wrap flex-column full-width">
<span class="regular-price eur-price total<?= $_product->is_on_sale() ? "--with-sale" : "" ?>" data-product-id="<?= $product_id ?>" ><?= secondary_price_output(calculate_price_with_print($product_price, $print_type, $product_id, $europa_league) * $cart_item['quantity']); ?></span>
<span class="sale-price eur-price" style="<?= $_product->is_on_sale() ? "" : "display: none" ?>" data-product-id="<?= $product_id ?>" ><?= secondary_price_output(calculate_price_with_print($product_sale_price, $print_type, $product_id, $europa_league) * $cart_item['quantity']); ?></span>
</div>
<?php } ?>
<div class="d-flex flex-wrap flex-column align-items-end full-width">
<span class="regular-price total<?= $_product->is_on_sale() ? "--with-sale" : "" ?>" data-product-id="<?= $product_id ?>" ><?= wc_price(calculate_price_with_print($product_price, $print_type, $product_id, $europa_league) * $cart_item['quantity']); ?></span>
<span class="sale-price" style="<?= $_product->is_on_sale() ? "" : "display: none" ?>" data-product-id="<?= $product_id ?>" ><?= wc_price(calculate_price_with_print($product_sale_price, $print_type, $product_id, $europa_league) * $cart_item['quantity']); ?></span>
</div>
</div>
</div>
</div>
</div>
</div>
</td>
<td>
<span class="sale-price" style="<?= $_product->is_on_sale() ? "" : "display: none;" ?>"><?= price_with_secondary(calculate_price_with_print($product_sale_price, $print_type, $product_id, $europa_league)); ?></span>
<span class="price<?= $_product->is_on_sale() ? "--with-sale" : "" ?>"><?= price_with_secondary(calculate_price_with_print($product_price, $print_type, $product_id, $europa_league)); ?></span>
</td>
<td class="text-center">
<div class="form-group quantity">
<span data-cart-item-key="<?= $cart_item_key ?>" data-change-qt="down" data-product-id="<?= $product_id ?>" class="minus <?= ($cart_item['quantity'] == '1') ? 'minus--unclickable' : ''; ?>">-</span>
<input disabled type="number" value="<?= $cart_item['quantity']; ?>" class="form-control" name="quantity">
<span data-cart-item-key="<?= $cart_item_key ?>" data-change-qt="up" data-product-id="<?= $product_id ?>" class="plus">+</span>
</div>
</td>
<td class="price line-total"><?= price_with_secondary(calculate_price_with_print($_product->is_on_sale() ? $product_sale_price : $product_price, $print_type, $product_id, $europa_league) * $cart_item['quantity']) ?></td>
<td>
<a data-product-id="<?= $product_id ?>" data-cart-item-remove="<?= $cart_item_key ?>" class="cart-remove">
<svg class="icon icon-delete"><use xlink:href="<?php echo THEMEROOT; ?>/assets/icons/icons.svg#icon-delete"></use></svg>
</a>
<?php if ($_product->is_on_sale()){ ?>
<?= get_lowest_price_html($_product); ?>
<?php } ?>
</td>
</tr>
<?php
}
} ?>
</tbody>
</table>
<div class="d-flex justify-content-end">
<div class="order-details">
<div class="box">
<div class="shipping-pricing item">
<div class="form-group mr-15">
<label class="form-label uppercase"><?php _e('Dostava', 'dinamo_shop'); ?></label>
<select style="width:160px;" class="country-picker" name="delivery">
<option></option>
<?php
global $woocommerce;
$countries_obj = new WC_Countries();
$countries = $countries_obj->__get('countries');
foreach($countries as $key => $country){
?>
<option <?= $key == WC()->customer->get_shipping_country() ? "selected='selected'" : "" ?> value="<?= $key ?>" ><?= $country; ?></option>
<?php } ?>
</select>
</div>
<?php
$packages = WC()->shipping()->get_packages();
foreach ( $packages as $i => $package ) {
$chosen_method = isset(WC()->session->chosen_shipping_methods[$i]) ? WC()->session->chosen_shipping_methods[$i] : '';
$product_names = array();
if (count($packages) > 1) {
foreach ($package['contents'] as $item_id => $values) {
$product_names[$item_id] = $values['data']->get_name() . ' ×' . $values['quantity'];
}
$product_names = apply_filters('woocommerce_shipping_package_details_array', $product_names, $package);
}
$available_methods = $package['rates'];
?>
<?php if ($available_methods) { ?>
<?php foreach ($available_methods as $method) :
?>
<div class="price-outter d-flex text-align-right align-self-end <?= $active_currency == "HRK" ? "" : "flex-row-reverse" ?>" style="<?= $has_secondary_currency ? "" : "width: unset;" ?>">
<?php if ($has_secondary_currency) { ?>
<span class="shipping-total-price price <?= $active_currency == "HRK" ? "eur-price" : "" ?>"> <?= secondary_price_output($method->cost); ?></span>
<?php } ?>
<span class="shipping-total-price price <?= $active_currency == "HRK" ? "" : "eur-price" ?>"> <?= wc_price($method->cost); ?></span>
</div>
<?php endforeach; ?>
<?php }
}?>
</div>
</div>
<div class="box">
<div class="item">
<label class="uppercase"><?php _e('Osnovica', 'dinamo_shop'); ?></label>
<div class="price-outter d-flex text-align-right <?= $active_currency == "HRK" ? "" : "flex-row-reverse" ?>" style="<?= $has_secondary_currency ? "" : "width: unset;" ?>">
<?php if ($has_secondary_currency) { ?>
<span class="price base-total-price <?= $active_currency == "HRK" ? "eur-price" : "" ?>"><?= secondary_price_output(WC()->cart->total - WC()->cart->tax_total); ?></span>
<?php } ?>
<span class="price base-total-price <?= $active_currency == "HRK" ? "" : "eur-price" ?>"><?= wc_price(WC()->cart->total - WC()->cart->tax_total); ?></span>
</div>
</div>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited ?>
<div class="item tax-item">
<label class="uppercase"><?php echo esc_html( $tax->label ); ?></label>
<div class="price-outter d-flex text-align-right <?= $active_currency == "HRK" ? "" : "flex-row-reverse" ?>" style="<?= $has_secondary_currency ? "" : "width: unset;" ?>">
<?php if ($has_secondary_currency) { ?>
<span class="price tax-total-price <?= $active_currency == "HRK" ? "eur-price" : "" ?>"><?php echo secondary_price_output( $tax->amount ); ?></span>
<?php } ?>
<span class="price tax-total-price <?= $active_currency == "HRK" ? "" : "eur-price" ?>"><?php echo wp_kses_post( $tax->formatted_amount ); ?></span>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="box">
<div class="item">
<label class="uppercase"><?php _e('Ukupno', 'dinamo_shop'); ?></label>
<div class="price-outter d-flex text-align-right <?= $active_currency == "HRK" ? "" : "flex-row-reverse" ?>" style="<?= $has_secondary_currency ? "" : "width: unset;" ?>">
<?php if ($has_secondary_currency) { ?>
<span class="total cart-total-price <?= $active_currency == "HRK" ? "eur-price" : "" ?>"><?= secondary_price_output(WC()->cart->total); ?></span>
<?php } ?>
<span class="total cart-total-price <?= $active_currency == "HRK" ? "" : "eur-price" ?>"><?= WC()->cart->get_total(); ?></span>
</div>
</div>
</div>
<div class="box">
<div class="item" id="coupon" style="display:none">
<div class="form-group full-width">
<label class="form-label"><?php _e('Unesite kod kupona', 'dinamo_shop'); ?></label>
<div class="input-button-group">
<input type="text" autocomplete="off" class="form-control full-width" name="coupon" placeholder="<?php _e('Ovdje unesite kod', 'dinamo_shop'); ?>">
<a href="#" class="btn btn-primary"><?php _e('Primjeni', 'dinamo_shop'); ?></a>
</div>
</div>
</div>
<p style="display:none;" class="success text-right mt-10"><?php _e('Uneseni kod je uspješno primjenjen!', 'dinamo_shop'); ?></p>
<div class="cart-error" style="max-width: 420px;">
<?php if($has_null) : ?>
<div class="cart-error__wrap">
<img src="<?= THEMEROOT ?>/assets/img/Error.svg" class="cart-error__img">
<div class="cart-error__text">
<h4>Dodali ste proizvod od 0€.<br>
Ispričavamo se na grešci te Vas molimo da uklonite proizvod prije nastavka.</h4>
</div>
</div>
<?php endif ?>
</div>
<div class="item mt-10 flex-wrap">
<div class="btn-group">
<a href="#" class="btn btn-ghost" data-toggle="#coupon"><?php _e('Imam kupon', 'dinamo_shop'); ?></a>
<a id="goToCheckout" <?= !$has_null ? 'href="' . wc_get_checkout_url() . '"' : '' ?> class="btn btn-primary"><?php _e('Odvedi me na plaćanje', 'dinamo_shop'); ?></a>
</div>
</div>
</div>
</div>
</div>
<?php do_action( 'woocommerce_after_cart_table' ); ?>
</form>
</div>
</div>