Set minimum per item + Distance rate

[ad_1]

I see the surcharge option, but this does not multiply by number of products

this seems to have done the trick, courtesy of chatgpt:

            // Count total items in the cart
            $total_items = 0;
            foreach ( $package['contents'] as $item_id => $values ) {
                $total_items += $values['quantity'];
            }

            $surcharge = $this->get_rate_field_value( 'surcharge', $rate, '' );

            if ( ! strlen( $surcharge ) ) {
                $surcharge = $this->surcharge;
            }

            if ( $surcharge ) {
                $surcharge_type = $this->get_rate_field_value( 'surcharge_type', $rate, 'inherit' );

                if ( ! $surcharge_type || 'inherit' === $surcharge_type ) {
                    $surcharge_type = $this->surcharge_type;
                }

                if ( ! $surcharge_type ) {
                    $surcharge_type="fixed";
                }

                if ( 'fixed' === $surcharge_type ) {
                    $cost += $surcharge * $total_items; // Apply surcharge per product
                } elseif ( 'percent' === $surcharge_type ) {
                    $cost += ( ( $cost * $surcharge ) / 100 );
                }
            }

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer