• mrvince

    (@vincenzbrandl)


    Hey together

    I only want to offer Shipping by Country for my vendors.
    I have activated shipping and the Shipping by Country option in my dashboard and thus released it for my vendors.
    In WooCommerce under the Shipping Zones setting, I created Store Shipping under “Places that are not covered by your other zones”.

    Now the problem: At checkout I get the following warning:

    Warning: Invalid argument supplied for foreach () in /homepages/24/d831969678/htdocs/clickandbuilds/Marktplatz/wp-content/plugins/woocommerce/includes/class-wc-shipping.php on line 321

    I also use a plugin from Angelleye (WooCommerce Multiple PayPal Accounts Plugin) to redirect the payments via PayPal directly to my vendors. When paying out, the shipping costs are distributed super randomly and the distribution of the shipping costs is not correct at all.

    Has that something to do with the warning in the checkout?
    I also deactivated the WCFM plug-in to possibly find the error, and then the warning no longer came … So is that a problem of WCFM?

    Did I set the shipping incorrectly at WCFM or WooCommerce?

    I would be very happy if you could help me, as it is unfortunately very urgent …

    Many Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WC Lovers

    (@wclovers)

    Are you using any other third party shipping plugin?

    I also use a plugin from Angelleye (WooCommerce Multiple PayPal Accounts Plugin) to redirect the payments via PayPal directly to my vendors. When paying out, the shipping costs are distributed super randomly and the distribution of the shipping costs is not correct at all.

    – Is this PayPal plugin support WCFM Marketplace plugin?

    Thread Starter mrvince

    (@vincenzbrandl)

    Are you using any other third party shipping plugin?

    No, there is no other plugin that could affect the shipping.

    – Is this PayPal plugin support WCFM Marketplace plugin?

    This is what the Developer of this Plugin told me:
    “It is compatible, however, you would have to create the rules for vendors manually. We do not (yet) have it setup to automatically create those rules like it does for WC Vendors and Dokan. This is coming soon.”

    I do the setting of the payments outside of WCFM.

    Plugin Author WC Lovers

    (@wclovers)

    OK.

    We have no idea about this plugin so it’s difficult for us to guide you properly.

    Thread Starter mrvince

    (@vincenzbrandl)

    Thanks again for your quick response.
    I have now found out that the problem has something to do with the shipping packages.

    I came across a snippet that is splitting Shipping Packages by shipping class:

    <?php
    /**
     * Split all shipping class 'A' products in a separate package
     */
    function custom_split_shipping_packages_shipping_class( $packages ) {
    
    	// Reset all packages
    	$packages              = array();
    	$regular_package_items = array();
    	$split_package_items   = array();
    
    	$split_shipping_class = 'a'; // Shipping class slug
    	foreach ( WC()->cart->get_cart() as $item_key => $item ) {
    
    		if ( $item['data']->needs_shipping() ) {
    
    			if ( $split_shipping_class == $item['data']->get_shipping_class() ) {
    				$split_package_items[ $item_key ] = $item;
    			} else {
    				$regular_package_items[ $item_key ] = $item;
    			}
    
    		}
    
    	}
    
    	// Create shipping packages
    	if ( $regular_package_items ) {
    		$packages[] = array(
    			'contents'        => $regular_package_items,
    			'contents_cost'   => array_sum( wp_list_pluck( $regular_package_items, 'line_total' ) ),
    			'applied_coupons' => WC()->cart->get_applied_coupons(),
    			'user'            => array(
    				 'ID' => get_current_user_id(),
    			),
    			'destination'    => array(
    				'country'    => WC()->customer->get_shipping_country(),
    				'state'      => WC()->customer->get_shipping_state(),
    				'postcode'   => WC()->customer->get_shipping_postcode(),
    				'city'       => WC()->customer->get_shipping_city(),
    				'address'    => WC()->customer->get_shipping_address(),
    				'address_2'  => WC()->customer->get_shipping_address_2()
    			)
    		);
    	}
    
    	if ( $split_package_items ) {
    		$packages[] = array(
    			'contents'        => $split_package_items,
    			'contents_cost'   => array_sum( wp_list_pluck( $split_package_items, 'line_total' ) ),
    			'applied_coupons' => WC()->cart->get_applied_coupons(),
    			'user'            => array(
    				 'ID' => get_current_user_id(),
    			),
    			'destination'    => array(
    				'country'    => WC()->customer->get_shipping_country(),
    				'state'      => WC()->customer->get_shipping_state(),
    				'postcode'   => WC()->customer->get_shipping_postcode(),
    				'city'       => WC()->customer->get_shipping_city(),
    				'address'    => WC()->customer->get_shipping_address(),
    				'address_2'  => WC()->customer->get_shipping_address_2()
    			)
    		);
    	}
    
    	return $packages;
    
    }
    add_filter( 'woocommerce_cart_shipping_packages', 'custom_split_shipping_packages_shipping_class' );

    Link to the Author/ Blog: https://jeroensormani.com/splitting-shipping-packages-in-woocommerce/ (There are also options to make packages by Product-ID or Category.)

    With this snippet, the distribution of the shipping costs in PayPal works perfectly.

    BUT:
    The snippet creates packages attached to the classes. Can you help me to create the snippet packages based on the vendors? For example with the Vendor Slug or Vendor-ID?

    I would be very happy if you could help me further – I would even make a small donation for it!

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Problem with Shipping-Costs’ is closed to new replies.