/**
	* Validate product quantity when Added to cart.
	* @since 1.1.6
	*/
	
	function isa_max_item_quantity_validation( $passed, $product_id, $quantity ) {
		global $woocommerce;
		$woocommerce_max_qty = get_option( 'isa_woocommerce_max_qty_limit' );
		$alread_in_cart = isa_get_qty_alread_in_cart( $product_id );
		$product = get_product( $product_id );
		$product_title = $product->post->post_title;

		if ( ! empty( $alread_in_cart ) ) {
			// there was already a quantity of this item in cart prior to this addition
			// Check if the total of $alread_in_cart + current addition quantity is more than our max
			$new_qty = $alread_in_cart + $quantity;
			if ( $new_qty > $woocommerce_max_qty ) {
				// oops. too much.
				$passed = false;
				wc_add_notice( sprintf( __( 'You can add a maximum of %1$s %2$s\'s to %3$s. You already have %4$s.', 'woocommerce-max-quantity' ), 
							$woocommerce_max_qty,
							$product_title,
							'<a href="' . $woocommerce->cart->get_cart_url() . '" title="' . __( 'Go to cart', 'woocommerce-max-quantity' ) . '">' . __( 'your cart', 'woocommerce-max-quantity' ) . '</a>',
							$alread_in_cart ), 'error' );

			}
		} else {
			// none were in cart previously

			// just in case they manually type in an amount greater than we allow, check the input number here too
			if ( $quantity > $woocommerce_max_qty ) {
				// oops. too much.
				wc_add_notice( sprintf( __( 'You can add a maximum of %1$s %2$s\'s to %3$s.', 'woocommerce-max-quantity' ),
							$woocommerce_max_qty,
							$product_title,
							'<a href="' . $woocommerce->cart->get_cart_url() . '" title="' . __( 'Go to cart', 'woocommerce-max-quantity' ) . '">' . __( 'your cart', 'woocommerce-max-quantity' ) . '</a>'), 'error' );
				$passed = false;
			}

		}

		return $passed;
	}
 /**
  * Validate product quantity when added to cart.
  * @since 1.1.6
  */
 function isa_max_item_quantity_validation($passed, $product_id, $quantity, $variation_id, $variations)
 {
     global $woocommerce;
     $woocommerce_max_qty = get_option('isa_woocommerce_max_qty_limit');
     $alread_in_cart = isa_get_qty_alread_in_cart($product_id, $variation_id);
     if (!empty($alread_in_cart)) {
         // there was already a quantity of this item in cart prior to this addition
         // Check if the total of $alread_in_cart + current addition quantity is more than our max
         $new_qty = $alread_in_cart + $quantity;
         if ($new_qty > $woocommerce_max_qty) {
             // oops. too much.
             $product = get_product($product_id);
             $product_title = $product->post->post_title;
             $woocommerce->add_error(sprintf(__("You can add a maximum of %s %s's to %s. You already have %s.", 'woocommerce_max_quantity'), $woocommerce_max_qty, $product_title, '<a href="' . $woocommerce->cart->get_cart_url() . '" title="Go to cart">' . __('your cart', '') . '</a>', $alread_in_cart));
             $passed = false;
         } else {
             // addition qty is okay
             $passed = true;
         }
     } else {
         // none were in cart previously, and we already have input limits in place, so no more checks are needed
         $passed = true;
     }
     return $passed;
 }