• Resolved tiagoalves83

    (@tiagoalves83)


    Hi,

    I already have 3000 products registered. They dont have HxWxL.So, I made some modifications in your script and everything is working fine. I am justing using the Weight of the products.

    Sharing the solution (maybe you can add to the core)
    First adding a new function into the wc-correios.php

    protected function is_virtual_order($package) {
    	foreach ( $package['contents'] as $item_id => $values ) {
    		$product = $values['data'];
    		if (!$product->is_virtual()) {
    			return false;
    		}
    	}
    	return true;
    }

    Then replace inside correios_connect( $package ) function the following code:

    if ( !empty( $measures['height'] ) && !empty( $measures['width'] ) && !empty( $measures['length'] ) ) {

    with:

    if ( !$this->is_virtual_order($package) ) {

    Warnings may be shown at max() functions calls inside Correios/Cubage.php… Just add a @ to ignore those warnings …

    You could add a setting ‘Ignore product cubage (just use weight)’

    Thank you.

    https://www.ads-software.com/extend/plugins/woocommerce-correios/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Claudio Sanches

    (@claudiosanches)

    Thanks but I will not do that.

    This flees the idea plugin.

    You could have avoided making that GoHorse my friend.

    There is a filter called “wccorreios_default_package” that you can use to define a standard size and do this instead.

    Thread Starter tiagoalves83

    (@tiagoalves83)

    I believe that GoHorse is add a comment “// Checks if the cart is not just virtual goods.” and actually checks the products measures, doesn’t it ?

    I made just a suggestion, you don’t need to offend programming skills of people.

    I will use the filter instead. Thanks.

    Plugin Author Claudio Sanches

    (@claudiosanches)

    Friend, making its solution, we have problems with products that are not marked as virtual and medium-sized lacking.

    My comment and verification observe whether there are dimensions.
    If not considered is that the product is virtual.

    Do you know something in the real world that does not have dimensions and measures?

    Thread Starter tiagoalves83

    (@tiagoalves83)

    Dude, it is your plugin. I appreciate the time you took to develop it.

    My suggestion was to add a option to just use the product weight for shipping calculation.

    Correios just cares if the box specs obeys minimun and maximum dimensions. Other than that, it will consider the weight for calculation.

    Telling the plugin to use just the weight of the products will make the store owner assumes responsability for the package dimensions.

    That is it.

    Plugin Author Claudio Sanches

    (@claudiosanches)

    I’m sorry.

    But I do not understand why you are nervous.
    The plugin already has the filter to do what you want.

    Here the solution to your problem:

    function cs_default_correios_package( $measures ) {
        // Gets Correios settings.
        $default = get_option( 'woocommerce_correios_settings' );
    
        // Sets default package for dimensions.
        $measures['height'] = array( $default['minimum_height'] );
        $measures['length'] = array( $default['minimum_length'] );
        $measures['width']  = array( $default['minimum_width'] );
    
        return $measures;
    }
    
    add_filter( 'wccorreios_default_package', 'cs_default_correios_package' );

    Use this code in your functions.php

    This seeing?
    Without GoHorse.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Suggestion’ is closed to new replies.