1 2 3 4 5 6 7 8 9 10 |
<?php $product = wc_get_product( get_the_ID() ); $add_to_cart_link = sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" class=" add_to_cart_button single_add_to_cart_button button product_type_%s">%s</a>', esc_url( $product->add_to_cart_url() ), $product->id, esc_attr( $product->product_type ), 'Mua ngay' ); echo $add_to_cart_link; ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<div class="bar_cart"> <?php global $woocommerce; //ob_start();?> <div class="cart"><a href="<?php echo WC()->cart->get_cart_url(); ?>" title="Xem giỏ hàng" rel="nofollow"><?php echo sprintf(_n('%d item', '%d sản phẩm', WC()->cart->cart_contents_count, 'woothemes'), WC()->cart->cart_contents_count);?> - <?php echo WC()->cart->get_cart_total(); ?> </a></div> <ul> <?php if ( sizeof( WC()->cart->get_cart() ) > 0 ) : ?> <?php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) : $_product = $cart_item['data']; // Chỉ hiển thị nếu cho phép if ( ! apply_filters('woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) || ! $_product->exists() || $cart_item['quantity'] == 0 )continue; // Lấy price $product_price = get_option( 'woocommerce_display_cart_prices_excluding_tax' ) == 'yes' || WC()->customer->is_vat_exempt() ? $_product->get_price_excluding_tax() : $_product->get_price(); $product_price = apply_filters( 'woocommerce_cart_item_price_html', woocommerce_price( $product_price ), $cart_item, $cart_item_key ); ?> <li><a class="cart-images" href="<?php echo get_permalink( $cart_item['product_id'] ); ?>" title="<?php echo apply_filters('woocommerce_widget_cart_product_title', $_product->get_title(), $_product ); ?>"> <?php echo $_product->get_image(); ?> </a><div class="cart-info"><div class="product-name"><a href="<?php echo get_permalink( $cart_item['product_id'] ); ?>" title="<?php echo apply_filters('woocommerce_widget_cart_product_title', $_product->get_title(), $_product ); ?>" class="cart_block_product_name"> <span class="quantity"><?php printf( '%s × %s', $cart_item['quantity'], $product_price ); ?></span> <?php echo apply_filters('woocommerce_widget_cart_product_title', $_product->get_title(), $_product ); ?></a></div></div></li> <?php endforeach; ?> <?php else : ?> <dt style="display: block;" class="first_item" data-id="cart_block_product_10_0_0"><?php _e('Chưa có sản phẩm trong giỏ hàng', 'woocommerce'); ?></dt> <?php endif; ?> <li><p class="cart-buttons"> <a id="button_order_cart" class="btn btn-default button button-small" href="<?php echo WC()->cart->get_cart_url(); ?>" title="Giỏ hàng" rel="nofollow">Giỏ hàng</a> <a id="button_order_cart" class="btn btn-default button button-small" href="<?php echo WC()->cart->get_checkout_url(); ?>" title="Thanh toán" rel="nofollow">Thanh toán</a> </p></li> </ul> </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
.bar_cart { width: 20%; float: left; position:relative; } .bar_menus_add_cart { background-color: #ddd; } .bar_cart ul { background-color: #eee; display:none; position:absolute; } .bar_cart ul li { display: block; float: left; } .bar_cart ul li a.cart-images { width: 30%; float: left; } .cart-info { width: 70%; float: right; padding-left: 15px; } |
1 2 3 4 5 6 |
$('.bar_cart .cart').mouseover(function(){ $('.bar_cart ul').show('slow'); }) $('.bar_cart ul').mouseleave(function(){ $('.bar_cart ul').hide('slow'); }) |
Tìm kiếm trên google:
-Hướng dẫn custom woocommerce
Mọi sự sao chép xin ghi rõ nguồn là fcwordpress.net
Chuyên trang về wordpress: hướng dẫn thiết kế theme, plugin, thủ thuật wordpress