Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/issue 2562 - Add Retail Delivery Fee for Colorado #2834

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

iyut
Copy link
Collaborator

@iyut iyut commented Dec 18, 2024

Description

Adding a function for custom surcharge ( retail delivery fee ) for Colorado state. This changes also introduce a new filter hook that the user can use to disable the custom surcharge addition.

Related issue(s)

Fixes #2562

Steps to reproduce & screenshots/GIFs

  1. Add product to the cart.
  2. Use any Colorado address for the shipping address.
  3. The Retail Delivery Fee will be displayed as a free on the cart.

Checklist

  • unit tests
  • changelog.txt entry added
  • readme.txt entry added

@iyut iyut self-assigned this Dec 18, 2024
@iyut iyut requested a review from bartech December 19, 2024 02:54
@iyut iyut marked this pull request as ready for review December 19, 2024 02:54
@iyut iyut requested a review from Abdalsalaam December 20, 2024 03:38
Copy link
Collaborator

@bartech bartech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to create separate file that have custom fees, maybe even folder to store logic per each case in separate file (function) that will return fee data or false.
In main hooked method check if $custom_fees contain item with $customer->get_shipping_country() . ':" . $customer->get_shipping_state().

$custom_fees = array(
	'US:CO' => 'custom_function_name'
);

If matched include custom fee logic file and run custom_function_name to check if fee should be applied, if should be applied return fee data.

array(
	'value' => 0.27 // can be calculated
	'label' => __( 'Retail Delivery Fee', 'woocommerce_services' ),
);

If fee should not be applied return false.

Comment on lines +1536 to +1538
if ( count( array_intersect( wc_get_chosen_shipping_method_ids(), apply_filters( 'woocommerce_local_pickup_methods', array( 'legacy_local_pickup', 'local_pickup' ) ) ) ) > 0 ) {
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check if all chosen methods wc_get_chosen_shipping_method_ids() are local_pickup, if anyone of them is not fee should be applied.

*
* @param WC_Cart $cart WooCommerce Cart object.
*/
public function add_custom_state_surcharge_fee( $cart ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to check if Colorado state Sales or Use Tax is charged on the items (see if we already have those taxes applied) as usually when items are exempt from state Sales or Use Tax they are exempt from Retail Delivery Fee.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Colorado Retail Delivery Fee
2 participants