Advertisement
danrancan

var/www/mcmo.is/wp-content/themes/h-code/woocommerce/cart/cart.php

Jul 6th, 2023
1,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.49 KB | Source Code | 0 0
  1. // /var/www/mcmo.is/wp-content/themes/h-code/woocommerce/cart/cart.php //
  2.  
  3. <?php
  4. /**
  5.  * Cart Page
  6.  *
  7.  * This template can be overridden by copying it to yourtheme/woocommerce/cart/cart.php.
  8.  *
  9.  * HOWEVER, on occasion WooCommerce will need to update template files and you
  10.  * (the theme developer) will need to copy the new files to your theme to
  11.  * maintain compatibility. We try to do this as little as possible, but it does
  12.  * happen. When this occurs the version of the template file will be bumped and
  13.  * the readme will list any important changes.
  14.  *
  15.  * @see     https://docs.woocommerce.com/document/template-structure/
  16.  * @package WooCommerce\Templates
  17.  * @version 7.8.0
  18.  */
  19.  
  20. defined( 'ABSPATH' ) || exit;
  21.  
  22. $hcode_cart_section_classes = $hcode_cart_coupon_classes = $hcode_cart_total_classes = '';
  23.  
  24. $hcode_layout_settings_single = hcode_option( 'hcode_layout_settings' );
  25.  
  26. switch( $hcode_layout_settings_single ) {
  27.     case 'hcode_layout_left_sidebar':
  28.     case 'hcode_layout_right_sidebar':
  29.         $hcode_cart_section_classes .= 'no-padding';
  30.         $hcode_cart_coupon_classes .= 'col-md-5 col-sm-12 calculate padding-five no-padding-bottom no-padding-right xs-padding-five-lr xs-margin-bottom-ten';
  31.         $hcode_cart_total_classes .= 'col-md-6 col-sm-12 col-md-offset-1 col-sm-offset-0 padding-five no-padding-bottom no-padding-left sm-no-padding xs-padding-five-lr';
  32.     break;
  33.     case 'hcode_layout_both_sidebar':
  34.         $hcode_cart_section_classes .= 'no-padding';
  35.         $hcode_cart_coupon_classes .= 'col-md-5 col-sm-12 calculate padding-five no-padding-bottom no-padding-right sm-padding-five-lr xs-margin-bottom-ten';
  36.         $hcode_cart_total_classes .= 'col-md-6 col-sm-12 col-md-offset-1 col-sm-offset-0 padding-five no-padding-bottom no-padding-left sm-no-padding sm-padding-five-lr';
  37.     break;
  38.     case 'hcode_layout_full_screen':
  39.         $hcode_cart_coupon_classes .= 'col-md-5 col-sm-5 calculate padding-five no-padding-bottom no-padding-right xs-margin-bottom-ten xs-padding-five-lr';
  40.         $hcode_cart_total_classes .= 'col-md-6 col-sm-7 col-md-offset-1 padding-five no-padding-bottom no-padding-left xs-padding-five-lr xs-no-padding-top';
  41.     break;
  42. }
  43. ?>
  44. <section class="<?php echo esc_attr( $hcode_cart_section_classes ); ?>">
  45.     <div class="container">
  46.         <div class="row">
  47.             <?php
  48.  
  49.             wc_print_notices();
  50.  
  51.             do_action( 'woocommerce_before_cart' ); ?>
  52.  
  53.             <form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
  54.  
  55.                 <div class="col-sm-12 shop-cart-table">
  56.  
  57.                     <?php
  58.  
  59.                     do_action( 'woocommerce_before_cart_table' );
  60.  
  61.                     switch( $hcode_layout_settings_single ) {
  62.                         case 'hcode_layout_left_sidebar':
  63.                         case 'hcode_layout_right_sidebar':
  64.                             echo '<div class="shopping-cart-scroll">';
  65.                         break;
  66.                         case 'hcode_layout_both_sidebar':
  67.                             echo '<div class="shopping-cart-scroll shopping-cart-both-col-scroll">';
  68.                         break;
  69.                         case 'hcode_layout_full_screen':
  70.                             echo '<div class="shopping-cart-scroll shopping-cart-full-screen-scroll">';
  71.                         break;
  72.                     }
  73.                     ?>
  74.  
  75.                         <table class="table shop-cart shop_table shop_table_responsive cart text-center woocommerce-cart-form__contents">
  76.                         <thead>
  77.                             <tr>
  78.                                 <th class="product-thumbnail first">&nbsp;</th>
  79.                                 <th class="product-name text-left text-uppercase font-weight-600 letter-spacing-2 text-small black-text"><?php esc_html_e( 'Product', 'H-Code' ); ?></th>
  80.                                 <th class="product-price text-left text-uppercase font-weight-600 letter-spacing-2 text-small black-text"><?php esc_html_e( 'Price', 'H-Code' ); ?></th>
  81.                                 <th class="product-quantity text-left text-uppercase font-weight-600 letter-spacing-2 text-small black-text"><?php esc_html_e( 'Quantity', 'H-Code' ); ?></th>
  82.                                 <th class="product-subtotal text-left text-uppercase font-weight-600 letter-spacing-2 text-small black-text"><?php esc_html_e( 'Subtotal', 'H-Code' ); ?></th>
  83.                                 <th class="product-remove">&nbsp;</th>
  84.                             </tr>
  85.                         </thead>
  86.                         <tbody>
  87.                             <?php do_action( 'woocommerce_before_cart_contents' ); ?>
  88.  
  89.                             <?php
  90.                             foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
  91.                                 $_product     = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
  92.                                 $product_id   = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
  93.  
  94.                                 if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
  95.                                     $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
  96.                                     ?>
  97.                                     <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
  98.  
  99.                                         <td class="product-thumbnail text-left">
  100.                                             <?php
  101.                                                 $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
  102.  
  103.                                                 if ( ! $product_permalink ) {
  104.                                                     echo $thumbnail; // PHPCS: XSS ok.
  105.                                                 } else {
  106.                                                     printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok.
  107.                                                 }
  108.                                             ?>
  109.                                         </td>
  110.  
  111.                                         <td class="product-name text-left" data-title="<?php esc_attr_e( 'Product', 'H-Code' ); ?>">
  112.                                             <?php
  113.  
  114.                                                 if ( ! $product_permalink ) {
  115.                                                     echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;' );
  116.                                                 } else {
  117.                                                     echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', sprintf( '<a class="margin-two-bottom" href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_name() ), $cart_item, $cart_item_key ) );
  118.                                                 }
  119.  
  120.                                                 do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
  121.  
  122.                                                 // Meta data
  123.                                                 echo wc_get_formatted_cart_item_data( $cart_item );
  124.  
  125.                                                 //sku
  126.                                                 if ( wc_product_sku_enabled() && ( $_product->get_sku() || $_product->is_type( 'variable' ) ) ) :
  127.                                                     echo '<span class="text-uppercase display-block text-small margin-two no-margin-top light-gray-text2">';
  128.                                                         esc_html_e( 'SKU:', 'H-Code' );
  129.                                                         echo ( $sku = $_product->get_sku() ) ? $sku : '';
  130.                                                     echo '</span>';
  131.                                                 endif;
  132.  
  133.                                                 // Backorder notification
  134.                                                 if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
  135.                                                     echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'H-Code' ) . '</p>' ) );
  136.                                                 }
  137.  
  138.                                                 if ( ! $product_permalink ) {
  139.                                                     echo '<a class="text-small" href="#"><i class="fa-solid fa-edit black-text"></i> '.esc_html__( 'Edit', 'H-Code' ).'</a>';
  140.                                                 } else {
  141.                                                     echo '<a class="text-small" href="'.esc_url( $product_permalink ).'"><i class="fa-solid fa-edit black-text"></i> '.esc_html__( 'Edit', 'H-Code' ).'</a>';
  142.                                                 }
  143.                                             ?>
  144.                                         </td>
  145.  
  146.                                         <td class="product-price text-left" data-title="<?php esc_attr_e( 'Price', 'H-Code' ); ?>">
  147.                                             <?php
  148.                                                 echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key );
  149.                                             ?>
  150.                                         </td>
  151.  
  152.                                         <td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'H-Code' ); ?>">
  153.                                             <?php
  154.                                                 if ( $_product->is_sold_individually() ) {
  155.                                                     $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
  156.                                                 } else {
  157.                                                     $product_quantity = woocommerce_quantity_input(
  158.                                                         array(
  159.                                                             'input_name'   => "cart[{$cart_item_key}][qty]",
  160.                                                             'input_value'  => $cart_item['quantity'],
  161.                                                             'max_value'    => $_product->get_max_purchase_quantity(),
  162.                                                             'min_value'    => '0',
  163.                                                             'product_name' => $_product->get_name(),
  164.                                                         ),
  165.                                                         $_product,
  166.                                                         false
  167.                                                     );
  168.                                                 }
  169.  
  170.                                                 echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item );
  171.                                             ?>
  172.                                         </td>
  173.  
  174.                                         <td class="product-subtotal text-left" data-title="<?php esc_attr_e( 'Subtotal', 'H-Code' ); ?>">
  175.                                             <?php
  176.                                                 echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key );
  177.                                             ?>
  178.                                         </td>
  179.  
  180.                                         <td class="product-remove text-center">
  181.                                             <?php
  182.                                                 echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  183.                                                     'woocommerce_cart_item_remove_link',
  184.                                                     sprintf(
  185.                                                         '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">&times;</a>',
  186.                                                         esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
  187.                                                         esc_html__( 'Remove this item', 'H-Code' ),
  188.                                                         esc_attr( $product_id ),
  189.                                                         esc_attr( $_product->get_sku() )
  190.                                                     ),
  191.                                                     $cart_item_key
  192.                                                 );
  193.                                             ?>
  194.                                         </td>
  195.                                     </tr>
  196.                                     <?php
  197.                                 }
  198.                             }
  199.  
  200.                             do_action( 'woocommerce_cart_contents' );
  201.  
  202.                             do_action( 'woocommerce_after_cart_contents' );
  203.  
  204.                         ?>
  205.                         </tbody>
  206.                         </table>
  207.                         <?php do_action( 'woocommerce_after_cart_table' ); ?>
  208.                     </div>
  209.                 </div>
  210.  
  211.                 <div class="col-sm-12">
  212.                     <div class="cupon padding-five border-top border-bottom">
  213.                         <?php global $woocommerce;?>
  214.                         <a href="<?php echo add_query_arg( 'empty-cart', '', esc_url( wc_get_cart_url() ) ); ?>" class="highlight-button btn btn-very-small no-margin pull-left"><?php esc_html_e('Empty Cart', 'H-Code');?></a>
  215.                         <?php do_action( 'hcode_woocommerce_continue_shopping_link' ); ?>
  216.                         <button type="submit" class="button  highlight-button btn btn-very-small no-margin pull-right" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'H-Code' ); ?>"><?php esc_html_e( 'Update cart', 'H-Code' ); ?></button>
  217.  
  218.                         <?php do_action( 'woocommerce_cart_actions' ); ?>
  219.                         <?php wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' ); ?>
  220.                     </div>
  221.                 </div>
  222.             </form>
  223.  
  224.                 <div class="<?php echo esc_attr( $hcode_cart_coupon_classes );?>">
  225.                     <?php if ( wc_coupons_enabled() ) { ?>
  226.                     <div class="panel panel-default border margin-five no-margin-top">
  227.                         <div role="tablist" id="headingOne" class="panel-heading no-padding">
  228.                             <a class="collapsed" data-toggle="collapse" data-parent="#collapse-two" href="#collapse-two-link1">
  229.                                 <h4 class="panel-title no-border black-text font-weight-600 letter-spacing-2"><?php esc_attr_e( 'Coupon code', 'H-Code' ); ?> <span class="pull-right"><i class="fa-solid fa-plus"></i></span></h4>
  230.                             </a>
  231.                         </div>
  232.                         <div id="collapse-two-link1" class="panel-collapse collapse">
  233.                             <div class="panel-body">
  234.                                 <form action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
  235.                                 <div class="coupon">
  236.                                     <input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php esc_attr_e( 'Coupon code', 'H-Code' ); ?>" />
  237.                                     <button type="submit" class="button highlight-button btn btn-very-small no-margin pull-left" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'H-Code' ); ?>"><?php esc_attr_e( 'Apply coupon', 'H-Code' ); ?></button>
  238.                                     <?php do_action( 'woocommerce_cart_coupon' ); ?>
  239.                                 </div>
  240.                                 </form>
  241.                             </div>
  242.                         </div>
  243.                     </div>
  244.                     <?php } ?>
  245.                 </div>
  246.                 <div class="<?php echo esc_attr( $hcode_cart_total_classes );?>">
  247.                     <?php woocommerce_cart_totals(); ?>
  248.                 </div>
  249.             <?php do_action( 'woocommerce_before_cart_collaterals' ); ?>
  250.             <div class="cart-collaterals">
  251.                 <?php
  252.                     /**
  253.                      * Cart collaterals hook.
  254.                      *
  255.                      * @hooked woocommerce_cross_sell_display
  256.                      * @hooked woocommerce_cart_totals - 10
  257.                      */
  258.                     do_action( 'woocommerce_cart_collaterals' );
  259.                 ?>
  260.             </div>
  261.             <?php do_action( 'woocommerce_after_cart' ); ?>
  262.         </div>
  263.     </div>
  264. </section>
Tags: wordpress
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement