WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce Correios
[resolved] Suggestion (6 posts)

  1. tiagoalves83
    Member
    Posted 2 years ago #

    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.

    http://wordpress.org/extend/plugins/woocommerce-correios/

  2. Claudio Sanches
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  3. tiagoalves83
    Member
    Posted 2 years ago #

    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.

  4. Claudio Sanches
    Member
    Plugin Author

    Posted 2 years ago #

    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?

  5. tiagoalves83
    Member
    Posted 2 years ago #

    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.

  6. Claudio Sanches
    Member
    Plugin Author

    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.