瀏覽代碼

Varia: Cleaning up mini cart styles

Allan Cole 5 年之前
父節點
當前提交
c2764d3c1b

+ 24 - 24
varia/inc/woocommerce.php

@@ -19,7 +19,7 @@ function varia_woocommerce_setup() {
 		'single_image_width'    => 750,
 		'thumbnail_image_width' => 350,
 		'product_grid'          => array(
-			'default_columns' => 2,
+			'default_columns' => 3,
 			'default_rows'    => 6,
 			'min_columns'     => 1,
 			'max_columns'     => 6,
@@ -91,7 +91,7 @@ if ( ! function_exists( 'varia_cart_link' ) ) {
 		$link_output = sprintf(
 			'<a class="woocommerce-cart-link" href="%1$s" title="%2$s">
 				%3$s
-				<span class="woocommerce-cart-subtotal">%4$s</span> - <span class="woocommerce-cart-count">%5$s</span>
+				<span class="woocommerce-cart-subtotal">%4$s</span> - <small class="woocommerce-cart-count">%5$s</small>
 			</a>',
 			esc_url( wc_get_cart_url() ),
 			esc_attr__( 'View your shopping cart', 'varia' ),
@@ -104,26 +104,6 @@ if ( ! function_exists( 'varia_cart_link' ) ) {
 	}
 }
 
-/**
- * Setup cart widget for main menu
- */
-if ( ! function_exists( 'varia_cart_widget' ) ) {
-	/**
-	 * Cart Items List
-	 * Ensure cart contents update when products are added to the cart via AJAX
-	 *
-	 * @param  array $fragments Fragments to refresh via AJAX.
-	 * @return array            Fragments to refresh via AJAX
-	 */
-	function varia_cart_widget() {
-		ob_start();
-		the_widget( 'WC_Widget_Cart', 'title=' );
-		$widget_output = ob_get_contents();
-		ob_end_clean();
-		return $widget_output;
-	}
-}
-
 /**
  * Setup cart fragments
  */
@@ -153,12 +133,32 @@ if ( ! function_exists( 'varia_cart_count_fragment' ) ) {
 	 */
 	function varia_cart_count_fragment( $fragments ) {
 		ob_start();
-		echo '<span class="woocommerce-cart-count">' . wp_kses_data( sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'varia' ), WC()->cart->get_cart_contents_count() ) ) . '</span>';
+		echo '<small class="woocommerce-cart-count">' . wp_kses_data( sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'varia' ), WC()->cart->get_cart_contents_count() ) ) . '</small>';
 		$fragments['.woocommerce-cart-count'] = ob_get_clean();
 		return $fragments;
 	}
 }
 
+/**
+ * Setup cart widget for main menu
+ */
+if ( ! function_exists( 'varia_cart_widget' ) ) {
+	/**
+	 * Cart Items List
+	 * Ensure cart contents update when products are added to the cart via AJAX
+	 *
+	 * @param  array $fragments Fragments to refresh via AJAX.
+	 * @return array            Fragments to refresh via AJAX
+	 */
+	function varia_cart_widget() {
+		ob_start();
+		the_widget( 'WC_Widget_Cart', 'title=' );
+		$widget_output = ob_get_contents();
+		ob_end_clean();
+		return $widget_output;
+	}
+}
+
 /**
  * Add cart fragment filters
  *
@@ -179,7 +179,7 @@ function varia_add_cart_menu( $nav, $args ) {
 	if ( $args->theme_location == 'menu-1' ) {
 		return sprintf(
 			'%1$s
-			<li class="menu-item wc-menu-item %6$s" title="%2$s">
+			<li class="menu-item woocommerce-menu-item %6$s" title="%2$s">
 				%4$s
 				<ul class="sub-menu">
 					<li class="woocommerce-cart-widget" title="%3$s">

+ 3 - 0
varia/sass/vendors/woocommerce/components/_mini-cart.scss

@@ -27,3 +27,6 @@ body[class*="woocommerce"] #page { // adding #page here to override default wc s
 	}
 }
 
+.woocommerce-cart #page .woocommerce-menu-item .sub-menu {
+	display: none;
+}

+ 4 - 0
varia/sass/vendors/woocommerce/pages/_cart.scss

@@ -38,6 +38,10 @@ body[class*="woocommerce"] #page { // adding #page here to override default wc s
 		font-family: #{map-deep-get($config-global, "font", "family", "primary")};
 		font-weight: 700;
 
+		a {
+			max-width: 50%;
+		}
+
 		dl.variation,
 		.wc-item-meta {
 

+ 8 - 0
varia/style-woocommerce.css

@@ -729,6 +729,10 @@ body[class*="woocommerce"] #page .main-navigation ul.product_list_widget li a {
 	padding: 0;
 }
 
+.woocommerce-cart #page .woocommerce-menu-item .sub-menu {
+	display: none;
+}
+
 /**
  * Product loops
  */
@@ -1300,6 +1304,10 @@ body[class*="woocommerce"] #page td.product-name {
 	font-weight: 700;
 }
 
+body[class*="woocommerce"] #page td.product-name a {
+	max-width: 50%;
+}
+
 body[class*="woocommerce"] #page td.product-name dl.variation dt,
 body[class*="woocommerce"] #page td.product-name dl.variation .wc-item-meta-label,
 body[class*="woocommerce"] #page td.product-name .wc-item-meta dt,