default.php
146 lines
| 1 | <?php |
| 2 | |
| 3 | defined('ABSPATH') || exit; |
| 4 | |
| 5 | if(is_checkout()) { |
| 6 | return; |
| 7 | } |
| 8 | |
| 9 | if(get_post_type() == \ShopEngine\Core\Template_Cpt::TYPE) { |
| 10 | |
| 11 | wc()->frontend_includes(); |
| 12 | |
| 13 | if(empty(WC()->cart->cart_contents)) { |
| 14 | |
| 15 | WC()->session = new WC_Session_Handler(); |
| 16 | WC()->session->init(); |
| 17 | WC()->customer = new WC_Customer(get_current_user_id(), true); |
| 18 | WC()->cart = new WC_Cart(); |
| 19 | |
| 20 | $demo_products = get_posts( |
| 21 | array( |
| 22 | 'post_type' => 'product', |
| 23 | 'numberposts' => 1, |
| 24 | 'post_status' => 'publish', |
| 25 | 'fields' => 'ids', |
| 26 | 'orderby' => 'ID', |
| 27 | 'order' => 'DESC' |
| 28 | ) |
| 29 | ); |
| 30 | if(!empty($demo_products)) { |
| 31 | foreach($demo_products as $id) { |
| 32 | WC()->cart->add_to_cart($id); |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | WC()->cart->calculate_totals(); |
| 37 | } |
| 38 | |
| 39 | ?> |
| 40 | |
| 41 | <?php |
| 42 | if (is_plugin_active('auxin-shop/auxin-shop.php')) { |
| 43 | |
| 44 | remove_action( 'woocommerce_proceed_to_checkout', 'auxshp_change_checkout_button_text', 20 ); |
| 45 | } |
| 46 | ?> |
| 47 | |
| 48 | <div class="shopengine-cart-totals"> |
| 49 | |
| 50 | <div class="cart_totals <?php echo (WC()->customer->has_calculated_shipping()) ? 'calculated_shipping' : ''; ?>"> |
| 51 | |
| 52 | <?php |
| 53 | // do_action('woocommerce_before_cart_totals'); cause issue with flatsome theme / add extra markup at the top of the main table |
| 54 | ?> |
| 55 | |
| 56 | <table cellspacing="0" class="shop_table shop_table_responsive"> |
| 57 | |
| 58 | <tr class="cart-subtotal"> |
| 59 | <th><?php esc_html_e('Subtotal', 'shopengine'); ?></th> |
| 60 | <td data-title="<?php esc_attr_e('Subtotal', 'shopengine'); ?>"><?php wc_cart_totals_subtotal_html(); ?></td> |
| 61 | </tr> |
| 62 | |
| 63 | <?php foreach(WC()->cart->get_coupons() as $code => $coupon) : ?> |
| 64 | <tr class="cart-discount coupon-<?php echo esc_attr(sanitize_title($code)); ?>"> |
| 65 | <th><?php wc_cart_totals_coupon_label($coupon); ?></th> |
| 66 | <td data-title="<?php echo esc_attr(wc_cart_totals_coupon_label($coupon, false)); ?>"><?php wc_cart_totals_coupon_html($coupon); ?></td> |
| 67 | </tr> |
| 68 | <?php endforeach; ?> |
| 69 | |
| 70 | <?php |
| 71 | |
| 72 | if(WC()->cart->needs_shipping() && WC()->cart->show_shipping()) : ?> |
| 73 | |
| 74 | <?php do_action('woocommerce_cart_totals_before_shipping'); ?> |
| 75 | |
| 76 | <?php wc_cart_totals_shipping_html(); ?> |
| 77 | |
| 78 | <?php do_action('woocommerce_cart_totals_after_shipping'); ?> |
| 79 | |
| 80 | <?php elseif(WC()->cart->needs_shipping() && 'yes' === get_option('woocommerce_enable_shipping_calc')) : ?> |
| 81 | |
| 82 | <tr class="shipping"> |
| 83 | <th><?php esc_html_e('Shipping', 'shopengine'); ?></th> |
| 84 | <td data-title="<?php esc_attr_e('Shipping', 'shopengine'); ?>"><?php woocommerce_shipping_calculator(); ?></td> |
| 85 | </tr> |
| 86 | |
| 87 | <?php endif; ?> |
| 88 | |
| 89 | <?php foreach(WC()->cart->get_fees() as $fee) : ?> |
| 90 | <tr class="fee"> |
| 91 | <th><?php echo esc_html($fee->name); ?></th> |
| 92 | <td data-title="<?php echo esc_attr($fee->name); ?>"><?php wc_cart_totals_fee_html($fee); ?></td> |
| 93 | </tr> |
| 94 | <?php endforeach; ?> |
| 95 | |
| 96 | <?php |
| 97 | if(wc_tax_enabled() && !WC()->cart->display_prices_including_tax()) { |
| 98 | $taxable_address = WC()->customer->get_taxable_address(); |
| 99 | $estimated_text = ''; |
| 100 | |
| 101 | if(WC()->customer->is_customer_outside_base() && !WC()->customer->has_calculated_shipping()) { |
| 102 | /* translators: %s location. */ |
| 103 | $estimated_text = sprintf(' <small>' . esc_html__('(estimated for %s)', 'shopengine') . '</small>', WC()->countries->estimated_for_prefix($taxable_address[0]) . WC()->countries->countries[$taxable_address[0]]); |
| 104 | } |
| 105 | |
| 106 | if('itemized' === get_option('woocommerce_tax_total_display')) { |
| 107 | foreach(WC()->cart->get_tax_totals() as $code => $tax) { |
| 108 | ?> |
| 109 | <tr class="tax-rate tax-rate-<?php echo esc_attr(sanitize_title($code)); ?>"> |
| 110 | <th><?php shopengine_content_render( esc_html($tax->label) . $estimated_text ); ?></th> |
| 111 | <td data-title="<?php echo esc_attr($tax->label); ?>"><?php echo wp_kses_post($tax->formatted_amount); ?></td> |
| 112 | </tr> |
| 113 | <?php |
| 114 | } |
| 115 | } else { |
| 116 | ?> |
| 117 | <tr class="tax-total"> |
| 118 | <th><?php shopengine_content_render(esc_html(WC()->countries->tax_or_vat()) . $estimated_text); ?></th> |
| 119 | <td data-title="<?php echo esc_attr(WC()->countries->tax_or_vat()); ?>"><?php wc_cart_totals_taxes_total_html(); ?></td> |
| 120 | </tr> |
| 121 | <?php |
| 122 | } |
| 123 | } |
| 124 | ?> |
| 125 | |
| 126 | <?php do_action('woocommerce_cart_totals_before_order_total'); ?> |
| 127 | |
| 128 | <tr class="order-total"> |
| 129 | <th><?php esc_html_e('Total', 'shopengine'); ?></th> |
| 130 | <td data-title="<?php esc_attr_e('Total', 'shopengine'); ?>"><?php wc_cart_totals_order_total_html(); ?></td> |
| 131 | </tr> |
| 132 | |
| 133 | <?php do_action('woocommerce_cart_totals_after_order_total'); ?> |
| 134 | |
| 135 | </table> |
| 136 | |
| 137 | <div class="wc-proceed-to-checkout"> |
| 138 | <?php do_action('woocommerce_proceed_to_checkout'); ?> |
| 139 | </div> |
| 140 | |
| 141 | <?php do_action('woocommerce_after_cart_totals'); ?> |
| 142 | |
| 143 | </div> |
| 144 | |
| 145 | </div> |
| 146 |