kreamweb
1/10/2017 - 11:29 AM

Calcola il totale solo dei prodotti dell'amministrazione

Calcola il totale solo dei prodotti dell'amministrazione

<?php

if ( class_exists( 'YWCM_Cart_Messages' ) && function_exists('yith_get_vendor')) {
		add_filter( 'ywcm_cart_total', 'ywcm_cart_total' );
		function ywcm_cart_total( $tot ) {
			$cart_content = WC()->cart->cart_contents;
			$tot = 0;
			if ( $cart_content ) {
				foreach ( $cart_content as $cart_item ) {
					$vendor = yith_get_vendor( $cart_item['product_id'], 'product' );
					if ( ! $vendor->is_valid() ) {
						$tot += $cart_item['data']->price;
					}
				}
			}

			return $tot;

		}
	}