�PNG  IHDR22?�� pHYs  �� OiCCPPhotoshop ICC profilexڝSgTS�=���BK���KoR RB���&*! J�!��Q�EEȠ�����Q, � ��!���������{�kּ������>���� �H3Q5� �B�������.@� $p�d!s�#�~<<+"��x� �M��0���B�\���t�8K�@z�B�@F���&S�`�cb�P-`'������{[�!�� e�Dh;��V�EX0fK�9�-0IWfH���� � 0Q��){`�##x��F�W<�+��*x��<�$9E�[-qWW.(�I+6aa�@.�y�2�4���������x����6��_-��"bb���ϫp@�t~��,/��;�m��%�h^ �u��f�@����W�p�~<�5�j>{�-�]c�K'Xt����o��(�h���w��?�G�%�fI�q^D$.Tʳ?�D��*�A��,���� �`6�B$��BB d�r`)��B(�Ͱ*`/�@4�Qh��p.�U�=p�a��(�� A�a!ڈb�X#����!�H�$ ɈQ"K�5H1R�T UH�=r9�\F��;�2����G1���Q=� �C��7�F� �dt1�����r�=�6��Ыhڏ>C�0��3�l0.��B�8, �c˱"� ���V����cϱw�E� 6wB aAHXLXN�H� $4� 7 �Q�'"��K�&���b21�XH,#��/{�C�7$�C2'��I��T��F�nR#�,��4H#���dk�9�, +ȅ����3��!�[ �b@q��S�(R�jJ��4�e�2AU��Rݨ�T5�ZB���R�Q��4u�9̓IK�����hh�i��t�ݕN��W���G���w ��Ljg(�gw��L�Ӌ�T071���oUX*�*|�� �J�&�*/T����ު U�U�T��^S}�FU3S� Ԗ�U��P�SSg�;���g�oT?�~Y��Y�L�OC�Q��_�� c�x,!k ��u�5�&���|v*�����=���9C3J3W�R�f?�q��tN �(���~���)�)�4L�1e\k����X�H�Q�G�6������E�Y��A�J'\'Gg����S�Sݧ �M=:��.�k���Dw�n��^��Lo��y���}/�T�m���G X� $� �<�5qo</���QC]�@C�a�a�ᄑ��<��F�F�i�\�$�m�mƣ&&!&KM�M�RM��)�;L;L���͢�֙5�=1�2��כ߷`ZxZ,����eI��Z�Yn�Z9Y�XUZ]�F���%ֻ�����N�N���gð�ɶ�����ۮ�m�}agbg�Ů��}�}��= ���Z~s�r:V:ޚΜ�?}����/gX���3��)�i�S��Ggg�s�󈋉K��.�>.���Ƚ�Jt�q]�z���������ۯ�6�i�ܟ�4�)�Y3s���C�Q��? ��0k߬~OCO�g��#/c/�W�װ��w��a�>�>r��>�<7�2�Y_�7��ȷ�O�o�_��C#�d�z����%g��A�[��z|!��?:�e����A���AA�������!h�쐭!��Α�i�P~���a�a��~ '���W�?�p�X�1�5w��Cs�D�D�Dޛg1O9�-J5*>�.j<�7�4�?�.fY��X�XIlK9.*�6nl������� �{�/�]py�����.,:�@L�N8��A*��%�w%� y��g"/�6ш�C\*N�H*Mz�쑼5y$�3�,幄'���L Lݛ:��v m2=:�1����qB�!M��g�g�fvˬe����n��/��k���Y- �B��TZ(�*�geWf�͉�9���+��̳�ې7�����ᒶ��KW-X潬j9�������(�x��oʿ�ܔ���Ĺd�f�f���-�[����n �ڴ �V����E�/��(ۻ��C���<��e����;?T�T�T�T6��ݵa��n��{��4���[���>ɾ�UUM�f�e�I���?�������m]�Nmq����#�׹���=TR��+�G�����w- 6 U����#pDy��� �� :�v�{���vg/jB��F�S��[b[�O�>����z�G��499�?r����C�d�&����ˮ/~�����јѡ�򗓿m|������������x31^�V���w�w��O�| (�h���SЧ��������c3-� cHRMz%������u0�`:�o�_�F5IDATx��ytUս�?�;���fN$$��@B�!�k��� -*�gE���j�O�kQ�ʠ`U�B_ �AÐ0%�Ȕ�@r3ޛ;߳��$�@��v����^�s����������$��ߢ !�W��5�̱'-٘������4�>�Rƫ$�G��0U�H}�_ _� #��k�MJ/=�9Du *ڲ�k�PQ;0��j|�*�$�^컂脛y���>�z×� B��� ��(�:$�ʔ_�6��C!B����MVx��a��ζyY����j��ƋY2�9�F�{r��r�딟F��Q��hY6��� x��[l��RC��������nt@��;P��3��� F�w��7��:�P���ɋ'���mj���Bƪ�$�Q�L��y��߷g��\���z����v5�p�v$�v櫻�`6~K �Y�X����,�:��"�o�e0II"(��,������l_�C���/4�+f�E�!q��:����u����c��樼.UE�@� �]K�W���$-�h]�JG���Dz)�`��.�A/ ���mᏣc�3jK� �!�>���$�Q�!�_�? \�C2(E �M$Z I{�U���s�ǣ���=��@Բe ޻��W�����@ �w����}�9v,)��.}*|"�s��di���,���G�]W�AC�������|<����[��ߕ������K�*�G nߴ!��‹��J�!��6(L�a)��Am��������;adf��:�xm��nh�;֦I��(���o�C~ډa?�=��s����h��E������xp����)���_���t��W�����´;8���`dz=(��@@�+,�;�`�fhl��XȌ�3,uI�~z(J����� �ZX�A����H'�À�㜦�82|��a�n�z2��I���� ���EY�h�ε<�0�q�{��C��v�˅��?"@��χ�x�WS+��N�~�KQ�J�8ل�� _.W��� !TU{�����,��"�� �;�������HI S� ��))�o�1�H�D� ���� (� ;����"Ҕ��,���� �F=���O��&�Ph>�`���y��߲ &S��P�<��'��1s�1cĂ�N����2)����@�u��tv��<�+�-&�����h��[!FSG���' � z z0��<����8d&�����E0�,��<��"!P�b4��� �{S�����X����.�囤���T��hEF��X�q0"-<����h���]�Py*����F⩍��@v�˂�Y08�� .q��a��s����(!<̫1�3�L�H��7sYW�`��qtu�\7��?�@�Y�� %Ka�x�GZ�*W�P��y�����N0r9��Z�c�%���q,��k�����!!,��>���IB��� �x1�Xu�Y���v-���ֺ��N������JP��a�2`�e5��w��u;�6�i���̃��(K���ťa��(l51��JL��O'%���]���ٖ뿉!��{*�p+f ���i8��D�ȑ���ܩ�M��V��ӟz��x�7Z�1i}�^͜���6e����x��)u�d�ˏ�V�eG�\�X1�����=n�U'�~Y����L�\,�(d!x ,�:�TW8� M`r���@��r+v�Q0��>^;˴�VbF��('����� �*O��i��j�Ӆ����^�S3&� ���{������.ی�� N;��NU%d0�Ce\r"�C�b��&t7N�7��� �ȪD�[%l�۪�$��'m?�A9tI�9>��NVL ��� 6v~M�����ъ�B���0����9$&=ώm��W�0���L���&��E���f�f��'+�9��hv��7,���M��6�D�&�^� �����8 D֮�����o��k^z��O��hP�8q�5d*��YVq3�{��������#LX4�?��jP=3�~�؅c�ݰ�̱�ұ��8̲��2�G�����j��έ�9��w7���U�X�w�85C��?!I&���o&����L���I#�^�eV�,�^t5�k� �xs˛\��U�8��."���{���ǵ�l4��ݼ�;��r"���G�/~���gJV�N糦��ZZ^k+NN�D��I$�=OE�z����|*�*{��%k���G��>�`9��b;�s���8,�qs��c��.b��q�%�>r��n�R�Ƨ�%�,�A��le#�8���}; 21�0�b�&�QX�f���q�00����$>�h�N�'�a3��A���/�r ��L5�8�GԲ'�����w;��c#�q1���h$*��V^�k��QĽ�b:i������� ����H F#�_���,��]g����Ը����`RUU���� ��"�qD���>-��ϤI�~��3�̴�����NZ[[555�eeek7�m����YF#[��Đ��R��i��L�H�r ��@��J-�Pŝ��_|�-��6y��ks�V�U~��6���w.����(��0A� 4��f��� /���C�xŊ�ٳ����z=6�����rg���mKo��o�/����a�g���?'9%9��P��斓��~���L{�� �H��{AW��B��$����v�1b�&Mb�ر��ر#�0`�`xMBp! )Z�Nmo�mZ�g�}�eذaWTVV ���'99��C5��&�&+5�bT>|8��PUUETT����&���t��~TE%��'������b�tEGG;RSS�S�N�v��ѯ��t����u1@�ޚ"f��͈���r'L�Ph��m��ƌ�74o��`�x�q�P���NRSS�X,�����l&&&��MFFA!-��`��ҷ�n��Yuu�����x<I�LB%����KԒ50�!�3�bz�����ʸKL���;---�l6[��`��������Ȏ;�����egg4��!D�T��jWujyZ��������K����%����p�^���X,6��sV=�ܖ����6�3�X ���4ҿ��A2�&����_k�;d�� �VfOIEND�B`� 0x0x
PHP 8.1.34
Preview: wc-cart-functions.php Size: 21.58 KB
/home2/astrociv/public_html/rudraraksham.com/wp-content/plugins/woocommerce/includes/wc-cart-functions.php
<?php
/**
 * WooCommerce Cart Functions
 *
 * Functions for cart specific things.
 *
 * @package WooCommerce\Functions
 * @version 2.5.0
 */

use Automattic\Jetpack\Constants;
use Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils;
use Automattic\WooCommerce\Enums\OrderStatus;
use Automattic\WooCommerce\Enums\ProductType;
use Automattic\WooCommerce\StoreApi\Utilities\LocalPickupUtils;

defined( 'ABSPATH' ) || exit;

/**
 * Prevent password protected products being added to the cart.
 *
 * @param  bool $passed     Validation.
 * @param  int  $product_id Product ID.
 * @return bool
 */
function wc_protected_product_add_to_cart( $passed, $product_id ) {
	if ( post_password_required( $product_id ) ) {
		$passed = false;
		wc_add_notice( __( 'This product is protected and cannot be purchased.', 'woocommerce' ), 'error' );
	}
	return $passed;
}
add_filter( 'woocommerce_add_to_cart_validation', 'wc_protected_product_add_to_cart', 10, 2 );

/**
 * Clears the cart session when called.
 */
function wc_empty_cart() {
	if ( ! isset( WC()->cart ) || '' === WC()->cart ) {
		WC()->cart = new WC_Cart();
	}
	WC()->cart->empty_cart( false );
}

/**
 * Retrieves unvalidated referer from '_wp_http_referer' or HTTP referer.
 *
 * Do not use for redirects, use {@see wp_get_referer()} instead.
 *
 * @since 2.6.1
 * @return string|false Referer URL on success, false on failure.
 */
function wc_get_raw_referer() {
	if ( function_exists( 'wp_get_raw_referer' ) ) {
		return wp_get_raw_referer();
	}

	if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { // WPCS: input var ok, CSRF ok.
		return wp_unslash( $_REQUEST['_wp_http_referer'] ); // WPCS: input var ok, CSRF ok, sanitization ok.
	} elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) { // WPCS: input var ok, CSRF ok.
		return wp_unslash( $_SERVER['HTTP_REFERER'] ); // WPCS: input var ok, CSRF ok, sanitization ok.
	}

	return false;
}

/**
 * Add to cart messages.
 *
 * @param int|array $products Product ID list or single product ID.
 * @param bool      $show_qty Should quantities be shown? Added in 2.6.0.
 * @param bool      $return   Return message rather than add it.
 *
 * @return mixed
 */
function wc_add_to_cart_message( $products, $show_qty = false, $return = false ) {
	$titles = array();
	$count  = 0;

	if ( ! is_array( $products ) ) {
		$products = array( $products => 1 );
		$show_qty = false;
	}

	if ( ! $show_qty ) {
		$products = array_fill_keys( array_keys( $products ), 1 );
	}

	$product_id = null;
	foreach ( $products as $product_id => $qty ) {
		/**
		 * Filters the quantity HTML for the add to cart message.
		 *
		 * @since 2.6.1
		 * @param string $qty_html The quantity HTML.
		 * @param int    $product_id The product ID.
		 */
		$title = apply_filters( 'woocommerce_add_to_cart_qty_html', ( 1 !== $qty ? wc_stock_amount( $qty ) . ' &times; ' : '' ), $product_id );

		/**
		 * Filters the item name in quotes for the add to cart message.
		 *
		 * @since 2.6.1
		 * @param string $item_name_in_quotes The item name in quotes.
		 * @param int    $product_id The product ID.
		 */
		$title .= apply_filters(
			'woocommerce_add_to_cart_item_name_in_quotes',
			sprintf(
				/* translators: %s: product name */
				_x( '&ldquo;%s&rdquo;', 'Item name in quotes', 'woocommerce' ),
				wp_strip_all_tags( get_the_title( $product_id ) )
			),
			$product_id
		);

		$titles[] = $title;
		$count   += $qty;
	}

	$titles = array_filter( $titles );
	/* translators: %s: product name */
	$added_text = sprintf( _n( '%s has been added to your cart.', '%s have been added to your cart.', $count, 'woocommerce' ), wc_format_list_of_items( $titles ) );

	// Output success messages.
	$wp_button_class = wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '';
	if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
		$return_to = apply_filters( 'woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wp_validate_redirect( wc_get_raw_referer(), false ) : wc_get_page_permalink( 'shop' ) );
		$message   = sprintf( '%s <a href="%s" class="button wc-forward%s">%s</a>', esc_html( $added_text ), esc_url( $return_to ), esc_attr( $wp_button_class ), esc_html__( 'Continue shopping', 'woocommerce' ) );
	} elseif ( ! CartCheckoutUtils::has_cart_page() ) {
		$message = sprintf( '%s', esc_html( $added_text ) );
	} else {
		$message = sprintf( '%s <a href="%s" class="button wc-forward%s">%s</a>', esc_html( $added_text ), esc_url( wc_get_cart_url() ), esc_attr( $wp_button_class ), esc_html__( 'View cart', 'woocommerce' ) );
	}

	if ( has_filter( 'wc_add_to_cart_message' ) ) {
		wc_deprecated_function( 'The wc_add_to_cart_message filter', '3.0', 'wc_add_to_cart_message_html' );
		$message = apply_filters( 'wc_add_to_cart_message', $message, $product_id );
	}

	$message = apply_filters( 'wc_add_to_cart_message_html', $message, $products, $show_qty );

	if ( $return ) {
		return $message;
	} else {
		wc_add_notice( $message, apply_filters( 'woocommerce_add_to_cart_notice_type', 'success' ) );
	}
}

/**
 * Comma separate a list of item names, and replace final comma with 'and'.
 *
 * @param  array $items Cart items.
 * @return string
 */
function wc_format_list_of_items( $items ) {
	$item_string = '';

	foreach ( $items as $key => $item ) {
		$item_string .= $item;

		if ( count( $items ) === $key + 2 ) {
			$item_string .= ' ' . __( 'and', 'woocommerce' ) . ' ';
		} elseif ( count( $items ) !== $key + 1 ) {
			$item_string .= ', ';
		}
	}

	return $item_string;
}

/**
 * Clear cart after payment.
 */
function wc_clear_cart_after_payment() {
	global $wp;

	$should_clear_cart_after_payment = false;
	$after_payment                   = false;

	// If the order has been received, clear the cart.
	if ( ! empty( $wp->query_vars['order-received'] ) ) {

		$order_id  = absint( $wp->query_vars['order-received'] );
		$order_key = isset( $_GET['key'] ) ? wc_clean( wp_unslash( $_GET['key'] ) ) : ''; // WPCS: input var ok, CSRF ok.

		if ( $order_id > 0 ) {
			$order = wc_get_order( $order_id );

			if ( $order instanceof WC_Order && hash_equals( $order->get_order_key(), $order_key ) ) {
				$should_clear_cart_after_payment = true;
				$after_payment                   = true;
			}
		}
	}

	// If the order is awaiting payment, and we haven't already decided to clear the cart, check the order status.
	if ( is_object( WC()->session ) && WC()->session->order_awaiting_payment > 0 && ! $should_clear_cart_after_payment ) {
		$order = wc_get_order( WC()->session->order_awaiting_payment );

		if ( $order instanceof WC_Order && $order->get_id() > 0 ) {
			// If the order status is neither pending, failed, nor cancelled, the order must have gone through.
			$should_clear_cart_after_payment = ! $order->has_status( array( OrderStatus::FAILED, OrderStatus::PENDING, OrderStatus::CANCELLED ) );
			$after_payment                   = true;
		}
	}

	// If it doesn't look like a payment happened, bail early.
	if ( ! $after_payment ) {
		return;
	}

	/**
	 * Determine whether the cart should be cleared after payment.
	 *
	 * @since 9.3.0
	 * @param bool $should_clear_cart_after_payment Whether the cart should be cleared after payment.
	 */
	$should_clear_cart_after_payment = apply_filters( 'woocommerce_should_clear_cart_after_payment', $should_clear_cart_after_payment );

	if ( $should_clear_cart_after_payment ) {
		WC()->cart->empty_cart();
	}
}
add_action( 'template_redirect', 'wc_clear_cart_after_payment', 20 );

/**
 * Get the subtotal.
 */
function wc_cart_totals_subtotal_html() {
	echo WC()->cart->get_cart_subtotal(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

/**
 * Get shipping methods.
 */
function wc_cart_totals_shipping_html() {
	$packages = WC()->shipping()->get_packages();
	$first    = true;

	foreach ( $packages as $i => $package ) {
		$chosen_method = isset( WC()->session->chosen_shipping_methods[ $i ] ) ? WC()->session->chosen_shipping_methods[ $i ] : '';
		$product_names = array();

		if ( count( $packages ) > 1 ) {
			foreach ( $package['contents'] as $item_id => $values ) {
				$product_names[ $item_id ] = $values['data']->get_name() . ' &times;' . $values['quantity'];
			}
			$product_names = apply_filters( 'woocommerce_shipping_package_details_array', $product_names, $package );
		}

		wc_get_template(
			'cart/cart-shipping.php',
			array(
				'package'                  => $package,
				'available_methods'        => $package['rates'],
				'show_package_details'     => count( $packages ) > 1,
				'show_shipping_calculator' => is_cart() && apply_filters( 'woocommerce_shipping_show_shipping_calculator', $first, $i, $package ),
				'package_details'          => implode( ', ', $product_names ),
				'package_name'             => $package['package_name'],
				'index'                    => $i,
				'chosen_method'            => $chosen_method,
				'formatted_destination'    => WC()->countries->get_formatted_address( $package['destination'], ', ' ),
				'has_calculated_shipping'  => WC()->customer->has_calculated_shipping(),
			)
		);

		$first = false;
	}
}

/**
 * Get taxes total.
 */
function wc_cart_totals_taxes_total_html() {
	echo apply_filters( 'woocommerce_cart_totals_taxes_total_html', wc_price( WC()->cart->get_taxes_total() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

/**
 * Get a coupon label.
 *
 * @param string|WC_Coupon $coupon Coupon data or code.
 * @param bool             $echo   Echo or return.
 *
 * @return string
 */
function wc_cart_totals_coupon_label( $coupon, $echo = true ) {
	if ( is_string( $coupon ) ) {
		$coupon = new WC_Coupon( $coupon );
	}

	/* translators: %s: coupon code */
	$label = apply_filters( 'woocommerce_cart_totals_coupon_label', sprintf( esc_html__( 'Coupon: %s', 'woocommerce' ), $coupon->get_code() ), $coupon );

	if ( $echo ) {
		echo $label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	} else {
		return $label;
	}
}

/**
 * Get coupon display HTML.
 *
 * @param string|WC_Coupon $coupon Coupon data or code.
 */
function wc_cart_totals_coupon_html( $coupon ) {
	if ( is_string( $coupon ) ) {
		$coupon = new WC_Coupon( $coupon );
	}

	$amount               = WC()->cart->get_coupon_discount_amount( $coupon->get_code(), WC()->cart->display_cart_ex_tax );
	$discount_amount_html = '-' . wc_price( $amount );

	if ( $coupon->get_free_shipping() && empty( $amount ) ) {
		$discount_amount_html = __( 'Free shipping coupon', 'woocommerce' );
	}

	$discount_amount_html = apply_filters( 'woocommerce_coupon_discount_amount_html', $discount_amount_html, $coupon );
	// translators: %s: coupon code.
	$coupon_html = $discount_amount_html . ' <a role="button" aria-label="' . esc_attr( sprintf( __( 'Remove %s coupon', 'woocommerce' ), $coupon->get_code() ) ) . '" href="' . esc_url( add_query_arg( 'remove_coupon', rawurlencode( $coupon->get_code() ), Constants::is_defined( 'WOOCOMMERCE_CHECKOUT' ) ? wc_get_checkout_url() : wc_get_cart_url() ) ) . '" class="woocommerce-remove-coupon" data-coupon="' . esc_attr( $coupon->get_code() ) . '">' . __( '[Remove]', 'woocommerce' ) . '</a>';

	echo wp_kses( apply_filters( 'woocommerce_cart_totals_coupon_html', $coupon_html, $coupon, $discount_amount_html ), array_replace_recursive( wp_kses_allowed_html( 'post' ), array( 'a' => array( 'data-coupon' => true ) ) ) ); // phpcs:ignore PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound
}

/**
 * Get order total html including inc tax if needed.
 */
function wc_cart_totals_order_total_html() {
	$value = '<strong>' . WC()->cart->get_total() . '</strong> ';

	// If prices are tax inclusive, show taxes here.
	if ( wc_tax_enabled() && WC()->cart->display_prices_including_tax() ) {
		$tax_string_array = array();
		$cart_tax_totals  = WC()->cart->get_tax_totals();

		if ( get_option( 'woocommerce_tax_total_display' ) === 'itemized' ) {
			foreach ( $cart_tax_totals as $code => $tax ) {
				$tax_string_array[] = sprintf( '%s %s', $tax->formatted_amount, $tax->label );
			}
		} elseif ( ! empty( $cart_tax_totals ) ) {
			$tax_string_array[] = sprintf( '%s %s', wc_price( WC()->cart->get_taxes_total( true, true ) ), WC()->countries->tax_or_vat() );
		}

		if ( ! empty( $tax_string_array ) ) {
			$taxable_address = WC()->customer->get_taxable_address();
			if ( WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping() ) {
				$country = WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ];
				/* translators: 1: tax amount 2: country name */
				$tax_text = wp_kses_post( sprintf( __( '(includes %1$s estimated for %2$s)', 'woocommerce' ), implode( ', ', $tax_string_array ), $country ) );
			} else {
				/* translators: %s: tax amount */
				$tax_text = wp_kses_post( sprintf( __( '(includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) ) );
			}

			$value .= '<small class="includes_tax">' . $tax_text . '</small>';
		}
	}

	echo apply_filters( 'woocommerce_cart_totals_order_total_html', $value ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

/**
 * Get the fee value.
 *
 * @param object $fee Fee data.
 */
function wc_cart_totals_fee_html( $fee ) {
	$cart_totals_fee_html = WC()->cart->display_prices_including_tax() ? wc_price( $fee->total + $fee->tax ) : wc_price( $fee->total );

	echo apply_filters( 'woocommerce_cart_totals_fee_html', $cart_totals_fee_html, $fee ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

/**
 * Get a shipping methods full label including price.
 *
 * @param  WC_Shipping_Rate $method Shipping method rate data.
 * @return string
 */
function wc_cart_totals_shipping_method_label( $method ) {
	$label     = $method->get_label();
	$has_cost  = 0 < $method->cost;
	$hide_cost = ! $has_cost && in_array( $method->get_method_id(), array( 'free_shipping', 'local_pickup' ), true );

	if ( $has_cost && ! $hide_cost ) {
		if ( WC()->cart->display_prices_including_tax() ) {
			$label .= ': ' . wc_price( $method->cost + $method->get_shipping_tax() );
			if ( $method->get_shipping_tax() > 0 && ! wc_prices_include_tax() ) {
				$label .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>';
			}
		} else {
			$label .= ': ' . wc_price( $method->cost );
			if ( $method->get_shipping_tax() > 0 && wc_prices_include_tax() ) {
				$label .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
			}
		}
	}

	return apply_filters( 'woocommerce_cart_shipping_method_full_label', $label, $method );
}

/**
 * Round discount.
 *
 * @param  double $value Amount to round.
 * @param  int    $precision DP to round.
 * @return float
 */
function wc_cart_round_discount( $value, $precision ) {
	return wc_round_discount( $value, $precision );
}

/**
 * Gets chosen shipping method IDs from chosen_shipping_methods session, without instance IDs.
 *
 * @since  2.6.2
 * @return string[]
 */
function wc_get_chosen_shipping_method_ids() {
	if ( ! is_callable( array( WC()->session, 'get' ) ) ) {
		return array();
	}

	$chosen_methods = WC()->session->get( 'chosen_shipping_methods', array() );
	$method_ids     = array();

	foreach ( $chosen_methods as $chosen_method ) {
		if ( ! is_string( $chosen_method ) ) {
			continue;
		}
		$chosen_method = explode( ':', $chosen_method );
		$method_ids[]  = current( $chosen_method );
	}

	return $method_ids;
}

/**
 * Get chosen method for package from session.
 *
 * @since  3.2.0
 * @param  int   $key Key of package.
 * @param  array $package Package data array.
 * @return string|bool Either the chosen method ID or false if nothing is chosen yet.
 */
function wc_get_chosen_shipping_method_for_package( $key, $package ) {
	if ( ! is_callable( array( WC()->session, 'get' ) ) ) {
		return false;
	}

	$chosen_methods = WC()->session->get( 'chosen_shipping_methods', array() );
	$chosen_method  = isset( $chosen_methods[ $key ] ) ? $chosen_methods[ $key ] : false;
	$changed        = wc_shipping_methods_have_changed( $key, $package );

	// This is deprecated but here for BW compat. Remove in 4.0.0.
	$method_counts = WC()->session->get( 'shipping_method_counts' );

	if ( ! empty( $method_counts[ $key ] ) ) {
		$method_count = absint( $method_counts[ $key ] );
	} else {
		$method_count = 0;
	}

	if ( ! isset( $package['rates'] ) || ! is_array( $package['rates'] ) ) {
		$package['rates'] = array();
	}

	// If not set, not available, or available methods have changed, set to the DEFAULT option.
	if ( ! $chosen_method || $changed || ! isset( $package['rates'][ $chosen_method ] ) || count( $package['rates'] ) !== $method_count ) {
		$chosen_method          = wc_get_default_shipping_method_for_package( $key, $package, $chosen_method );
		$chosen_methods[ $key ] = $chosen_method;
		$method_counts[ $key ]  = count( $package['rates'] );

		WC()->session->set( 'chosen_shipping_methods', $chosen_methods );
		WC()->session->set( 'shipping_method_counts', $method_counts );

		/**
		 * Fires when a shipping method is chosen.
		 *
		 * @since 3.2.0
		 * @param string $chosen_method Chosen shipping method. e.g. flat_rate:1.
		 */
		do_action( 'woocommerce_shipping_method_chosen', $chosen_method );
	}
	return $chosen_method;
}

/**
 * Choose the default method for a package.
 *
 * @since  3.2.0
 * @param  int    $key Key of package.
 * @param  array  $package Package data array.
 * @param  string $chosen_method Chosen shipping method. e.g. flat_rate:1.
 * @return string
 */
function wc_get_default_shipping_method_for_package( $key, $package, $chosen_method ) {
	$rate_keys               = array_keys( $package['rates'] );
	$local_pickup_method_ids = LocalPickupUtils::get_local_pickup_method_ids();

	if ( 'shortcode' === WC()->cart->cart_context ) {
		$default = current( $rate_keys );
	} else {
		// No default means that when you enter block checkout, shipping is chosen rather than pickup. We should only do this if there are shipping methods available other than local pickup.
		$default = CartCheckoutUtils::shipping_methods_exist() ? '' : current( $rate_keys );

		// Default to the first method in the package that isn't a local pickup method.
		foreach ( $rate_keys as $rate_key ) {
			$rate_method_id = current( explode( ':', $rate_key ) );
			if ( ! in_array( $rate_method_id, $local_pickup_method_ids, true ) ) {
				$default = $rate_key;
				break;
			}
		}

		// When shipping costs are hidden until an address is entered, don't auto-select pickup as the default.
		// Without this, pickup gets silently selected because it's the only remaining rate after filtering.
		if (
			'' === $default
			&& 'yes' === get_option( 'woocommerce_shipping_cost_requires_address' )
			&& WC()->customer instanceof \WC_Customer
			&& ! WC()->customer->has_full_shipping_address()
		) {
			/**
			 * Filters the default shipping method for a package.
			 *
			 * @since 3.2.0
			 * @param string $default Default shipping method.
			 * @param array  $rates   Shipping rates.
			 * @param string $chosen_method Chosen method id.
			 */
			return (string) apply_filters( 'woocommerce_shipping_chosen_method', $default, $package['rates'], $chosen_method );
		}
	}

	/**
	 * If the customer has selected local pickup, keep it selected if it's still in the package. We don't want to auto
	 * toggle between shipping and pickup even if available shipping methods are changed.
	 *
	 * This is important for block-based checkout where there is an explicit toggle between shipping and pickup.
	 */
	$chosen_method_id       = current( explode( ':', $chosen_method ) );
	$chosen_method_exists   = in_array( $chosen_method, $rate_keys, true );
	$is_local_pickup_chosen = in_array( $chosen_method_id, $local_pickup_method_ids, true );

	// Default to local pickup if its chosen already.
	if ( $chosen_method_exists && $is_local_pickup_chosen ) {
		$default = $chosen_method;

	} else {
		// Check coupons to see if free shipping is available. If it is, we'll use that method as the default.
		$coupons = WC()->cart->get_coupons();
		foreach ( $coupons as $coupon ) {
			if ( $coupon->get_free_shipping() ) {
				foreach ( $rate_keys as $rate_key ) {
					if ( 0 === stripos( $rate_key, 'free_shipping' ) ) {
						$default = $rate_key;
						break;
					}
				}
				break;
			}
		}
	}

	/**
	 * Filters the default shipping method for a package.
	 *
	 * @since 3.2.0
	 * @param string $default Default shipping method.
	 * @param array  $rates   Shipping rates.
	 * @param string $chosen_method Chosen method id.
	 */
	return (string) apply_filters( 'woocommerce_shipping_chosen_method', $default, $package['rates'], $chosen_method );
}

/**
 * See if the methods have changed since the last request.
 *
 * @since  3.2.0
 * @param  int   $key Key of package.
 * @param  array $package Package data array.
 * @return bool
 */
function wc_shipping_methods_have_changed( $key, $package ) {
	if ( ! is_callable( array( WC()->session, 'get' ) ) ) {
		return false;
	}

	// Lookup previous methods from session.
	$previous_shipping_methods = WC()->session->get( 'previous_shipping_methods' );
	// Get new and old rates.
	$new_rates  = array_keys( $package['rates'] );
	$prev_rates = isset( $previous_shipping_methods[ $key ] ) ? $previous_shipping_methods[ $key ] : false;
	// Update session.
	$previous_shipping_methods[ $key ] = $new_rates;
	WC()->session->set( 'previous_shipping_methods', $previous_shipping_methods );
	return $new_rates !== $prev_rates;
}

/**
 * Gets a hash of important product data that when changed should cause cart items to be invalidated.
 *
 * The woocommerce_cart_item_data_to_validate filter can be used to add custom properties.
 *
 * @param WC_Product $product Product object.
 * @return string
 */
function wc_get_cart_item_data_hash( $product ) {
	return md5(
		wp_json_encode(
			apply_filters(
				'woocommerce_cart_item_data_to_validate',
				array(
					'type'       => $product->get_type(),
					'attributes' => ProductType::VARIATION === $product->get_type() ? $product->get_variation_attributes() : '',
				),
				$product
			)
		)
	);
}

Directory Contents

Dirs: 28 × Files: 115
Name Size Perms Modified Actions
abstracts DIR
- drwxr-xr-x 2026-07-28 11:37:05
Edit Download
admin DIR
- drwxr-xr-x 2026-07-28 11:37:06
Edit Download
blocks DIR
- drwxr-xr-x 2026-07-28 11:37:06
Edit Download
cli DIR
- drwxr-xr-x 2026-07-28 11:37:06
Edit Download
- drwxr-xr-x 2026-07-28 11:37:06
Edit Download
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
emails DIR
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
export DIR
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
gateways DIR
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
import DIR
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
- drwxr-xr-x 2026-07-28 11:36:53
Edit Download
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
legacy DIR
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
libraries DIR
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
queue DIR
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
rest-api DIR
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
shipping DIR
- drwxr-xr-x 2026-07-28 11:36:53
Edit Download
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
tracks DIR
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
traits DIR
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
walkers DIR
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
- drwxr-xr-x 2026-07-28 11:37:07
Edit Download
widgets DIR
- drwxr-xr-x 2026-07-28 11:37:08
Edit Download
133.30 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
12.69 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
5.27 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
4.68 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
3.45 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
1.78 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
6.89 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
35.04 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
10.41 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
13.51 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
3.37 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
25.37 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
28.48 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
75.50 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
50.48 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
3.34 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
23.08 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
51.69 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
44.64 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
3.37 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
10.34 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
33.28 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
1.29 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
6.59 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
2.26 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
6.59 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
7.34 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
36.64 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
28.54 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
39.64 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
4.24 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
48.17 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
34.44 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
30.43 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
1.99 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
11.46 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
4.33 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
107.57 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
1.28 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
3.90 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
9.41 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
2.33 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
8.98 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
4.08 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
9.99 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
5.80 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
18.33 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
9.58 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
6.50 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
22.70 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
2.52 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
5.99 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
78.37 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
14.40 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
6.24 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
39.09 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
29.65 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
1.79 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
13.61 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
14.69 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
17.22 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
7.87 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
13.18 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
4.98 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
4.59 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
6.81 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
2.27 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
2.70 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
25.30 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
20.22 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
37.55 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
4.00 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
7.74 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
15.44 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
5.05 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
21.55 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
276 B lrw-r--r-- 2026-07-28 11:37:06
Edit Download
24.57 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
9.34 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
13.08 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
5.00 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
13.03 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
18.82 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
24.96 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
39.87 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
20.42 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
51.50 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
5.79 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
32.24 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
63.94 KB lrw-r--r-- 2026-07-28 11:37:06
Edit Download
14.83 KB lrw-r--r-- 2026-07-28 11:37:07
Edit Download
22.81 KB lrw-r--r-- 2026-07-28 11:37:07
Edit Download
4.17 KB lrw-r--r-- 2026-07-28 11:37:07
Edit Download
21.58 KB lrw-r--r-- 2026-07-28 11:37:07
Edit Download
15.53 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
79.00 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
5.56 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
40.38 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
49.91 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
2.43 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
8.49 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
43.99 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
5.03 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
5.97 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
9.99 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
69.18 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
13.93 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
17.43 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
148.55 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
12.84 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
24.63 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
108.05 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
36.36 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
7.49 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
2.01 KB lrw-r--r-- 2026-07-28 11:37:08
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 0xNothings — Secure File Manager. All rights reserved. Built with ❤️ & Tailwind x Dark UI