✏️ 正在编辑: cart.php
路径:
/home/h359620/public_html/wp-content/themes/datis/woocommerce/cart/cart.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php /** * Cart Page * * @package WooCommerce\Templates * @version 10.1.0 */ if (! defined('ABSPATH')) { exit(); } do_action('woocommerce_before_cart'); if (WC()->cart->is_empty()) { wc_get_template('cart/cart-empty.php'); do_action('woocommerce_after_cart'); return; } ?> <div id="datis-cart-root"> <?php if (WC()->cart->is_empty()) : ?> <?php wc_get_template('cart/cart-empty.php'); ?> <?php else : ?> <form class="cart page-cart d-flex mt-4 mt-lg-0 flex-column flex-lg-row align-items-start justify-content-between gap-3" action="<?php echo esc_url(wc_get_cart_url()); ?>" method="post"> <div class="cart-content col-12 col-lg-9 m-0 "> <div class="cart-wrapper"> <p class="cart-heading"> <?php esc_html_e('Cart', 'datis'); ?> </p> <div class="products d-flex flex-column gap-3 mt-4"> <?php foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) : $_product = $cart_item['data']; $product_id = $cart_item['product_id']; if (! $_product || ! $_product->exists() || $cart_item['quantity'] <= 0) { continue; } $product_name = $_product->get_name(); $product_link = $_product->is_visible() ? $_product->get_permalink($cart_item) : ''; $qty = (int) $cart_item['quantity']; // تصویر $image_url = wp_get_attachment_image_url($_product->get_image_id(), 'woocommerce_thumbnail'); if (! $image_url) { $image_url = wc_placeholder_img_src('woocommerce_thumbnail'); } // ----------------------------- // قیمتها فقط بر اساس خود محصول (بدون کوپن/تخفیف سبد) // ----------------------------- // قیمت واحد فعلی (sale اگر باشد) + مطابق تنظیمات نمایش مالیات $unit_discounted = (float) wc_get_price_to_display($_product); // قیمت واحد Regular (اگر نداشت، همان قیمت فعلی) $regular_raw = $_product->get_regular_price(); $unit_regular = $regular_raw !== '' ? (float) wc_get_price_to_display($_product, array('price' => $regular_raw)) : $unit_discounted; // قیمتهای کل (ضربدر تعداد) $total_regular = $unit_regular * $qty; // بدون تخفیف محصول $total_discounted = $unit_discounted * $qty; // با تخفیف محصول // درصد تخفیف (فقط بر اساس regular vs sale) $discount_percent = 0; if ($total_regular > 0 && $total_discounted < $total_regular) { $discount_percent = (int) round((($total_regular - $total_discounted) / $total_regular) * 100); } // لینک حذف $remove_url = wc_get_cart_remove_url($cart_item_key); // حداکثر تعداد برای max="" $max_qty = $_product->get_max_purchase_quantity(); ?> <div class="cart-item d-flex flex-column gap-3 gap-lg-0 flex-lg-row justify-content-between align-items-center"> <div class="col-12 col-lg-6 d-flex flex-row align-items-center gap-3"> <div class="products-img"> <?php if ($product_link) : ?> <a href="<?php echo esc_url($product_link); ?>"> <img src="<?php echo esc_url($image_url); ?>" alt="<?php echo esc_attr($product_name); ?>"> </a> <?php else : ?> <img src="<?php echo esc_url($image_url); ?>" alt="<?php echo esc_attr($product_name); ?>"> <?php endif; ?> </div> <h3 class="products-title"> <?php if ($product_link) : ?> <a href="<?php echo esc_url($product_link); ?>"><?php echo esc_html($product_name); ?></a> <?php else : ?> <?php echo esc_html($product_name); ?> <?php endif; ?> </h3> </div> <div class="col-12 col-lg-6 col-6 d-flex flex-column-reverse flex-lg-row-reverse align-items-start align-items-lg-center gap-3"> <!-- حذف محصول: همون SVG خودت، فقط تبدیل به لینک استاندارد ووکامرس --> <a class="remove-product" href="<?php echo esc_url($remove_url); ?>" aria-label="<?php echo esc_attr__('Remove this item', 'datis'); ?>" data-cart_item_key="<?php echo esc_attr($cart_item_key); ?>"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M9.1709 4C9.58273 2.83481 10.694 2 12.0002 2C13.3064 2 14.4177 2.83481 14.8295 4" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" /> <path d="M20.5001 6H3.5" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" /> <path d="M18.3737 15.3991C18.1967 18.054 18.1082 19.3815 17.2432 20.1907C16.3782 21 15.0478 21 12.387 21H11.6136C8.95284 21 7.62244 21 6.75743 20.1907C5.89242 19.3815 5.80393 18.054 5.62693 15.3991L5.16699 8.5M18.8337 8.5L18.6337 11.5" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" /> <path d="M9.5 11L10 16" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" /> <path d="M14.5 11L14 16" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" /> </svg> </a> <svg class="d-none d-lg-flex" width="1" height="70" viewBox="0 0 1 70" fill="none" xmlns="http://www.w3.org/2000/svg"> <line opacity="0.5" x1="0.5" y1="-2.18557e-08" x2="0.500003" y2="70" stroke="#22242B" stroke-opacity="0.3" /> </svg> <div class="d-flex flex-column align-items-start align-items-lg-end"> <div class="qty-control" data-qty-control> <button type="button" class="qty-btn qty-plus" aria-label="<?php echo esc_attr__('Increase quantity', 'datis'); ?>"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <g opacity="0.6"> <path d="M6 12H18" stroke="var(--datis-primary-color)" stroke-opacity="0.6" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 18V6" stroke="var(--datis-primary-color)" stroke-opacity="0.6" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </g> </svg> </button> <!-- همین input خودت، فقط داینامیک --> <input type="text" name="<?php echo esc_attr("cart[{$cart_item_key}][qty]"); ?>" value="<?php echo esc_attr($qty); ?>" inputmode="numeric" autocomplete="off" data-cart_item_key="<?php echo esc_attr($cart_item_key); ?>" <?php if ($max_qty > 0) : ?>max="<?php echo esc_attr($max_qty); ?>" <?php endif; ?>> <button type="button" class="qty-btn qty-minus" aria-label="<?php echo esc_attr__('Decrease quantity', 'datis'); ?>"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <g opacity="0.6"> <path d="M6 12H18" stroke="var(--datis-primary-color)" stroke-opacity="0.6" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </g> </svg> </button> </div> <div class="price d-flex flex-row-reverse align-items-center gap-3" data-unit-regular="<?php echo esc_attr($unit_regular); ?>" data-unit-discounted="<?php echo esc_attr($unit_discounted); ?>"> <?php if ($discount_percent > 0) : ?> <div class="discount-percentage"> <?php echo $discount_percent > 0 ? esc_html($discount_percent . '%') : ''; ?> </div> <?php endif; ?> <div class="regular-price"> <?php echo ($discount_percent > 0) ? wc_price($total_regular) : ''; ?> </div> <div class="price-amount"> <?php echo wc_price($total_discounted); ?> </div> </div> </div> </div> </div> <?php endforeach; ?> </div> <?php wp_nonce_field('woocommerce-cart', 'woocommerce-cart-nonce'); ?> </div> </div> <aside class="cart-sidebar col-12 col-lg-3 d-flex flex-column gap-3"> <div class="cart-wrapper "> <div class="price-details d-flex flex-column gap-3"> <div class="detail-items d-flex align-items-center justify-content-between"> <div class="detali-items-name"> <?php esc_html_e('Subtotal', 'datis'); ?> </div> <div class="detail-items-value"> <?php echo wc_price(WC()->cart->get_subtotal()); ?> </div> </div> <div class="detail-items d-flex align-items-center justify-content-between"> <div class="detali-items-name"> <?php esc_html_e('Shipping', 'datis'); ?> </div> <div class="detail-items-value"> <?php $shipping_total = WC()->cart->get_shipping_total(); echo $shipping_total !== '' ? wc_price((float) $shipping_total) : wc_price(0); ?> </div> </div> <div class="detail-items d-flex align-items-center justify-content-between"> <div class="detali-items-name"> <?php esc_html_e('Discount', 'datis'); ?> </div> <div class="detail-items-value"> <?php echo wc_price((float) WC()->cart->get_discount_total()); ?> </div> </div> <div class="detail-items d-flex align-items-center justify-content-between"> <div class="detali-items-name"> <?php esc_html_e('Total', 'datis'); ?> </div> <div class="detail-items-value"> <?php echo WC()->cart->get_total(); ?> </div> </div> </div> <button class="check-out-btn" type="button" onclick="window.location.href='<?php echo esc_url(wc_get_checkout_url()); ?>'"> <?php esc_html_e('Proceed to checkout', 'datis'); ?> </button> </div> <div class="discount-code"> <button type="button" class="discount-code-btn d-flex flex-row align-items-center justify-content-between" aria-expanded="false" aria-controls="coupon-panel"> <?php esc_html_e('Apply coupon code', 'datis'); ?> <div class="discount-code-btn-icon"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M19 9L12 15L10.25 13.5M5 9L7.33333 11" stroke="var(--datis-secondary-color)" stroke-width="1.125" stroke-linecap="round" stroke-linejoin="round" /> </svg> </div> </button> </div> <!-- این فرم کوپن داخل فرم اصلی نیست (nested form ممنوعه) --> <!-- بنابراین فقط محتوا را نگه میداریم و دکمه submit کوپن را به فرم اصلی میفرستیم --> <div id="coupon-panel" class="discount-code-panel" hidden> <div class="discount-code-form"> <div class="d-flex flex-column gap-2 position-relative"> <input type="text" name="coupon_code" class="input-text" placeholder="<?php echo esc_attr__('Coupon code', 'datis'); ?>" autocomplete="off" /> <button type="submit" class="button" name="apply_coupon" value="1"> <?php esc_html_e('Apply', 'datis'); ?> </button> </div> </div> </div> </aside> <?php wp_nonce_field('woocommerce-cart', 'woocommerce-cart-nonce'); ?> </form> <?php endif; ?> </div> <?php do_action('woocommerce_after_cart'); ?>
💾 保存文件
← 返回文件管理器