Plugin Directory

Changeset 3083378


Ignore:
Timestamp:
05/08/2024 01:54:55 PM (21 months ago)
Author:
dreamfox
Message:

Version 2.4.2

Location:
woocommerce-shipping-gateway-per-product
Files:
220 added
3 edited

Legend:

Unmodified
Added
Removed
  • woocommerce-shipping-gateway-per-product/trunk/inc/settings.php

    r3062774 r3083378  
    11<?php
    22
    3 function softsdev_product_shippings_settings()
    4 {
     3function softsdev_product_shippings_settings() {
    54    wp_register_script( 'dd_horztab_script', plugins_url( '/js/dd_horizontal_tabs.js', DFM_SGPPFW__FILE__ ) );
    65    wp_enqueue_script( 'dd_horztab_script' );
     
    87    add_filter( 'update_footer', 'softsdev_product_shippings_update_footer' );
    98    $setting_url = get_bloginfo( 'url' ) . '/wp-admin/admin.php?page=softsdev-product-shippings';
     9    $softsdev_wps_plugin_settings = get_option( 'sdwps_plugin_settings', array(
     10        'default_option_mp' => 'expensive',
     11    ) );
     12    $default_option_mp = $softsdev_wps_plugin_settings['default_option_mp'];
    1013    ?>
    1114    <div class="wrap wrap-mc-paid fs-section dd-wc-product-shippings"><div id="icon-tools" class="icon32"></div>
    1215    <h2 class="nav-tab-wrapper" id="settings">
    1316        <a href="<?php
    14     echo  $setting_url ;
     17    echo $setting_url;
    1518    ?>" class="nav-tab fs-tab nav-tab-active home">Settings</a>
    1619    </h2>
    1720    <h2 class="title"><?php
    18     echo  __( 'Woocommerce Product Shippings', 'softsdev' ) ;
     21    echo __( 'Woocommerce Product Shippings', 'softsdev' );
    1922    ?></h2></div>
    2023    <div class="left-dd-paid ">
     
    5154    ?>>
    5255                    <a href="<?php
    53     echo  admin_url( 'admin.php?page=softsdev-product-shippings-contact' ) ;
     56    echo admin_url( 'admin.php?page=softsdev-product-shippings-contact' );
    5457    ?>">Support</a>
    5558                </li>
     
    6972    add_filter( 'admin_footer_text', 'softsdev_product_shippings_footer_text' );
    7073    add_filter( 'update_footer', 'softsdev_product_shippings_update_footer' );
    71     echo  '<div class="wrap wrap-mc-paid"><div id="icon-tools" class="icon32"></div>' ;
    72     echo  '<h2 class="title">' . __( 'Woocommerce Product Shippings - Information', 'softsdev' ) . '</h2></div>' ;
     74    echo '<div class="wrap wrap-mc-paid"><div id="icon-tools" class="icon32"></div>';
     75    echo '<h2 class="title">' . __( 'Woocommerce Product Shippings - Information', 'softsdev' ) . '</h2></div>';
    7376    ?>
    7477            <p>This plugin for woocommerce lets you select the available shipping gateways for each individual product.
     
    7881            <p>This plugin allows you to improve your customer service by giving the best shipping service for your customers.</p>
    7982            <img src="<?php
    80     echo  plugins_url( 'img/attention.png', DFM_SGPPFW__FILE__ ) ;
     83    echo plugins_url( 'img/attention.png', DFM_SGPPFW__FILE__ );
    8184    ?>"><br>
    8285            IMPORTANT: We are using a new license system. If you have trouble with your license then see this link:<br>
    83             <a href="https://dreamfoxmedia.freshdesk.com/support/solutions/articles/72000533747-transferring-our-licenses-from-dreamfoxmedia-to-freemius/" target="_blank">Click here to see the complete article</a>
     86            <a href="https://support.dreamfoxmedia.com/kb/article/5/transferring-our-licenses-from-dreamfoxmedia-to-freemius" target="_blank">Click here to see the complete article</a>
    8487
    8588        </div>
     
    9396    add_filter( 'admin_footer_text', 'softsdev_product_shippings_footer_text' );
    9497    add_filter( 'update_footer', 'softsdev_product_shippings_update_footer' );
    95     echo  '<div class="wrap wrap-mc-paid"><div id="icon-tools" class="icon32"></div>' ;
    96     echo  '<h2 class="title">' . __( 'Woocommerce Product Shippings - Settings', 'softsdev' ) . '</h2></div>' ;
     98    echo '<div class="wrap wrap-mc-paid"><div id="icon-tools" class="icon32"></div>';
     99    echo '<h2 class="title">' . __( 'Woocommerce Product Shippings - Settings', 'softsdev' ) . '</h2></div>';
    97100    ?>
    98101            <div id="freeversion">
     
    100103                    <div>
    101104                        <h3 class="hndle"><?php
    102     echo  __( 'Multiple products in cart with different shipping gateway', 'softsdev' ) ;
     105    echo __( 'Multiple products in cart with different shipping gateway', 'softsdev' );
    103106    ?></h3>
    104107                        <select id="sdwps_default_payment" name="sdwps_setting[default_option_mp]" disabled="disabled">
     
    122125                        <br />
    123126                        <small><?php
    124     echo  __( 'In case of multiple products from diffrent shipping', 'softsdev' ) ;
     127    echo __( 'In case of multiple products from diffrent shipping', 'softsdev' );
    125128    ?></small>
    126129                    </div>
     
    139142    add_filter( 'admin_footer_text', 'softsdev_product_shippings_footer_text' );
    140143    add_filter( 'update_footer', 'softsdev_product_shippings_update_footer' );
    141     echo  '<div class="wrap wrap-mc-paid"><div id="icon-tools" class="icon32"></div>' ;
    142     echo  '<h2 class="title">' . __( 'Woocommerce Product Shippings - Newsletter', 'softsdev' ) . '</h2></div>' ;
     144    echo '<div class="wrap wrap-mc-paid"><div id="icon-tools" class="icon32"></div>';
     145    echo '<h2 class="title">' . __( 'Woocommerce Product Shippings - Newsletter', 'softsdev' ) . '</h2></div>';
    143146    ?>
    144147            <!-- Begin SendInBlue Form -->
     
    150153    add_filter( 'admin_footer_text', 'softsdev_product_shippings_footer_text' );
    151154    add_filter( 'update_footer', 'softsdev_product_shippings_update_footer' );
    152     echo  '<div class="wrap wrap-mc-paid"><div id="icon-tools" class="icon32"></div>' ;
    153     echo  '<h2 class="title">' . __( 'Woocommerce Product Shippings - FAQ', 'softsdev' ) . '</h2></div>' ;
     155    echo '<div class="wrap wrap-mc-paid"><div id="icon-tools" class="icon32"></div>';
     156    echo '<h2 class="title">' . __( 'Woocommerce Product Shippings - FAQ', 'softsdev' ) . '</h2></div>';
    154157    ?>
    155158            <div>
    156159                <!-- Begin freshdeskForm -->
    157                 If you want to read the FAQ about this plugin then click on below link. We will take you right there in a breeze.<br>You can also click on the help button in the bottom right corner to see the most ask questions.
     160                If you want to read the FAQ about this plugin then click on below link. We will take you right there in a breeze.<br>
     161                You can also click on the help button in the bottom right corner to see the most ask questions.
    158162                <script>
    159163                    window.fwSettings = {
     
    170174                </script>
    171175                <script type='text/javascript' src='https://widget.freshworks.com/widgets/72000002383.js' async defer></script>
    172                 <a href="https://dreamfoxmedia.freshdesk.com/support/solutions/72000275599/" target="_blank">Click here to see the Shipping Plugin FAQ</a>
     176                <a href="https://support.dreamfoxmedia.com/kb/section/8" target="_blank">Click here to see the Shipping Plugin FAQ</a>
     177
     178                <p><?php
     179    echo sprintf( __( 'If your answer can not be found in the resources listed above, please use our supportsystem <a href="%s">here</a>.' ), 'https://support.dreamfoxmedia.com' );
     180    ?></p>
     181                <p>Found a bug? Please open an issue <a href="https://support.dreamfoxmedia.com/support/tickets/create" target="_blank">here.</a></p>
    173182                <!--  END - We recommend to place the above code in head tag of your website html -->
    174183            </div>
     
    179188    add_filter( 'admin_footer_text', 'softsdev_product_shippings_footer_text' );
    180189    add_filter( 'update_footer', 'softsdev_product_shippings_update_footer' );
    181     echo  '<div class="wrap wrap-mc-paid"><div id="icon-tools" class="icon32"></div>' ;
    182     echo  '<h2 class="title">' . __( 'Woocommerce Product Shippings - Dreamfox Media Plugins', 'softsdev' ) . '</h2></div>' ;
     190    echo '<div class="wrap wrap-mc-paid"><div id="icon-tools" class="icon32"></div>';
     191    echo '<h2 class="title">' . __( 'Woocommerce Product Shippings - Dreamfox Media Plugins', 'softsdev' ) . '</h2></div>';
    183192    ?>
    184193            <?php
     
    187196    $response_code = wp_remote_retrieve_response_code( $response );
    188197    $response_body = wp_remote_retrieve_body( $response );
    189    
    190198    if ( $response_code != 200 || is_wp_error( $response ) ) {
    191         echo  '<div class="error below-h2"><p>There was an error retrieving the list from the server.</p></div>' ;
     199        echo '<div class="error below-h2"><p>There was an error retrieving the list from the server.</p></div>';
    192200        switch ( $response_code ) {
    193201            case '403':
    194                 echo  '<div class="error below-h2"><p>Seems your host is blocking <strong>' . dirname( $url ) . '</strong>. Please request to white list this domain </p></div>' ;
     202                echo '<div class="error below-h2"><p>Seems your host is blocking <strong>' . dirname( $url ) . '</strong>. Please request to white list this domain </p></div>';
    195203                break;
    196204        }
    197205        wp_die();
    198206    }
    199    
    200207    $addons = json_decode( $response_body );
    201208    ?>
     
    203210                <h3>Here you see our great Free and Premium Plugins of Dreamfox Media</h3>
    204211                <link href="<?php
    205     echo  plugins_url( '/css/addons-style.min.css', DFM_SGPPFW__FILE__ ) ;
     212    echo plugins_url( '/css/addons-style.min.css', DFM_SGPPFW__FILE__ );
    206213    ?>" rel="stylesheet" type="text/css">
    207214                <ul class="addons-wrap">
    208215                    <?php
    209216    foreach ( $addons as $addon ) {
    210         if ( !empty($addon->hidden) ) {
     217        if ( !empty( $addon->hidden ) ) {
    211218            continue;
    212219        }
     
    218225        ?>
    219226                        <li class="mymail-addon <?php
    220         if ( !empty($addon->is_free) ) {
    221             echo  ' is-free' ;
    222         }
    223         if ( !empty($addon->is_feature) ) {
    224             echo  ' is-feature' ;
    225         }
    226        
     227        if ( !empty( $addon->is_free ) ) {
     228            echo ' is-free';
     229        }
     230        if ( !empty( $addon->is_feature ) ) {
     231            echo ' is-feature';
     232        }
    227233        if ( isset( $addon->image ) ) {
    228234            $image = str_replace( 'http//', '//', $addon->image );
     
    230236            $image = str_replace( 'http//', '//', $addon->image_ );
    231237        }
    232        
    233238        ?>">
    234239                            <div class="bgimage" style="min-height: 500px; background-repeat: no-repeat; background-image:url(<?php
    235         echo  $image ;
     240        echo $image;
    236241        ?>)">
    237242                                <?php
    238        
    239243        if ( isset( $addon->wpslug ) ) {
    240244            ?>
    241245                                    <a href="plugin-install.php?tab=plugin-information&plugin=<?php
    242             echo  dirname( $addon->wpslug ) ;
     246            echo dirname( $addon->wpslug );
    243247            ?>&from=import&TB_iframe=true&width=745&height=745" class="thickbox">&nbsp;</a>
    244248                                <?php
     
    246250            ?>
    247251                                    <a href="<?php
    248             echo  $addon->link ;
     252            echo $addon->link;
    249253            ?>">&nbsp;</a>
    250254                                <?php
    251255        }
    252        
    253256        ?>
    254257                            </div>
    255258                            <h4><?php
    256         echo  $addon->name ;
     259        echo $addon->name;
    257260        ?></h4>
    258261                            <p class="author">by
    259262                                <?php
    260        
    261263        if ( $addon->author_url ) {
    262             echo  '<a href="' . $addon->author_url . '">' . $addon->author . '</a>' ;
     264            echo '<a href="' . $addon->author_url . '">' . $addon->author . '</a>';
    263265        } else {
    264             echo  $addon->author ;
    265         }
    266        
     266            echo $addon->author;
     267        }
    267268        ?>
    268269                            </p>
    269270                            <p class="description"><?php
    270         echo  $addon->description ;
     271        echo $addon->description;
    271272        ?></p>
    272273                            <div class="action-links">
    273274                                <?php
    274        
    275         if ( !empty($addon->wpslug) ) {
     275        if ( !empty( $addon->wpslug ) ) {
    276276            ?>
    277277                                    <?php
    278            
    279278            if ( is_dir( dirname( WP_PLUGIN_DIR . '/' . $addon->wpslug ) ) ) {
    280279                ?>
    281280                                        <?php
    282                
    283281                if ( is_plugin_active( $addon->wpslug ) ) {
    284282                    ?>
    285283                                            <a class="button" href="<?php
    286                     echo  wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $addon->wpslug, 'deactivate-plugin_' . $addon->wpslug ) ;
     284                    echo wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $addon->wpslug, 'deactivate-plugin_' . $addon->wpslug );
    287285                    ?>"><?php
    288286                    _e( 'Deactivate', 'mymail' );
     
    292290                    ?>
    293291                                            <a class="button" href="<?php
    294                     echo  wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon->wpslug, 'activate-plugin_' . $addon->wpslug ) ;
     292                    echo wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon->wpslug, 'activate-plugin_' . $addon->wpslug );
    295293                    ?>"><?php
    296294                    _e( 'Activate', 'mymail' );
     
    298296                                        <?php
    299297                }
    300                
    301298                ?>
    302299                                    <?php
     
    304301                ?>
    305302                                        <?php
    306                
    307303                if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
    308304                    ?>
    309305                                            <a class="button button-primary" href="<?php
    310                     echo  wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . dirname( $addon->wpslug ) . '&mymail-addon' ), 'install-plugin_' . dirname( $addon->wpslug ) ) ;
     306                    echo wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . dirname( $addon->wpslug ) . '&mymail-addon' ), 'install-plugin_' . dirname( $addon->wpslug ) );
    311307                    ?>"><?php
    312308                    _e( 'Install', 'mymail' );
     
    314310                                        <?php
    315311                }
    316                
    317312                ?>
    318313                                    <?php
    319314            }
    320            
    321315            ?>
    322316                                <?php
     
    324318            ?>
    325319                                    <a class="button button-primary" href="<?php
    326             echo  $addon->link ;
     320            echo $addon->link;
    327321            ?>"><?php
    328322            _e( 'Purchase', 'mymail' );
     
    330324                                <?php
    331325        }
    332        
    333326        ?>
    334327                            </div>
  • woocommerce-shipping-gateway-per-product/trunk/readme.txt

    r3062774 r3083378  
    9292== Changelog ==
    9393
     94= 2.4.2 =
     95* Bug fixed add to cart
     96
    9497= 2.4.1 =
    9598* tested with latest woocommerce
  • woocommerce-shipping-gateway-per-product/trunk/woocommerce-product-shippings.php

    r3062774 r3083378  
    55 * Plugin URI: https://www.dreamfoxmedia.com
    66 * Description: WooCommerce Shipping gateway per Product
    7  * Version: 2.4.1
     7 * Version: 2.4.2
    88 * Author: Dreamfox
    99 * Author URI: https://www.dreamfoxmedia.com
     
    2727    }
    2828} );
    29 
    3029if ( function_exists( 'dfm_sgppfw_fs' ) ) {
    3130    dfm_sgppfw_fs()->set_basename( false, __FILE__ );
    3231} else {
    33    
    3432    if ( !function_exists( 'dfm_sgppfw_fs' ) ) {
    3533        // Create a helper function for easy SDK access.
    36         function dfm_sgppfw_fs()
    37         {
    38             global  $dfm_sgppfw_fs ;
    39            
     34        function dfm_sgppfw_fs() {
     35            global $dfm_sgppfw_fs;
    4036            if ( !isset( $dfm_sgppfw_fs ) ) {
    4137                // Activate multisite network integration.
     
    5753                    'has_paid_plans' => true,
    5854                    'menu'           => array(
    59                     'slug'    => 'softsdev-product-shippings',
    60                     'support' => false,
    61                     'parent'  => array(
    62                     'slug' => 'woocommerce',
    63                 ),
    64                 ),
     55                        'slug'    => 'softsdev-product-shippings',
     56                        'support' => false,
     57                        'parent'  => array(
     58                            'slug' => 'woocommerce',
     59                        ),
     60                    ),
    6561                    'is_live'        => true,
    6662                ) );
    6763            }
    68            
    6964            return $dfm_sgppfw_fs;
    7065        }
    71        
     66
    7267        // Init Freemius.
    7368        dfm_sgppfw_fs();
     
    7570        do_action( 'dfm_sgppfw_fs_loaded' );
    7671    }
    77 
    78 }
    79 
     72}
    8073if ( !function_exists( 'is_plugin_active_for_network' ) || !function_exists( 'is_plugin_active' ) ) {
    8174    require_once ABSPATH . '/wp-admin/includes/plugin.php';
     
    9790}
    9891dfm_sgppfw_fs()->add_filter( 'hide_account_tabs', 'dfm_sgppfw_hide_account_tabs' );
    99 function dfm_sgppfw_hide_account_tabs()
    100 {
     92function dfm_sgppfw_hide_account_tabs() {
    10193    return true;
    10294}
     
    10597 * Check if WooCommerce is active
    10698 */
    107 
    10899if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && !function_exists( 'softsdev_product_shippings_settings' ) || is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) {
    109100    require_once dirname( __FILE__ ) . '/inc/settings.php';
    110     function softsdev_remove_empty_items( $ships )
    111     {
    112        
     101    function softsdev_remove_empty_items(  $ships  ) {
    113102        if ( is_array( $ships ) ) {
    114103            $result = array();
    115104            foreach ( $ships as $ship ) {
    116                 if ( strlen( trim( $ship ) ) > 0 ) {
     105                if ( is_string( $ship ) && strlen( trim( $ship ) ) > 0 ) {
    117106                    $result[] = $ship;
    118107                }
     
    121110            $result = $ships;
    122111        }
    123        
    124112        return $result;
    125113    }
    126    
     114
    127115    // display default admin notice
    128     function product_shipping_ignore_notice()
    129     {
     116    function product_shipping_ignore_notice() {
    130117        if ( isset( $_GET['product-shipping-ignore-notice'] ) ) {
    131118            update_option( 'product_shipping_alert', 1 );
    132119        }
    133120    }
    134    
     121
    135122    add_action( 'admin_init', 'product_shipping_ignore_notice' );
    136123    // Submenu on woocommerce section
     
    140127     */
    141128    if ( !function_exists( 'softsdev_notice' ) ) {
    142         function softsdev_notice( $message, $type )
    143         {
     129        function softsdev_notice(  $message, $type  ) {
    144130            ?>
    145131            <div class="<?php
    146             echo  $type ;
     132            echo $type;
    147133            ?> notice">
    148134                <p><?php
    149             echo  $message ;
     135            echo $message;
    150136            ?></p>
    151137            </div>
    152138            <?php
    153139        }
    154    
     140
    155141    }
    156142    /**
     
    159145     * @return string
    160146     */
    161     function softsdev_product_shippings_footer_text( $text )
    162     {
     147    function softsdev_product_shippings_footer_text(  $text  ) {
    163148        if ( isset( $_GET['page'] ) && strpos( plugin_basename( wp_unslash( $_GET['page'] ) ), 'softsdev-product-shippings' ) === 0 ) {
    164149            $text = '<a href="https://www.dreamfoxmedia.com" target="_blank">www.dreamfoxmedia.com</a>';
     
    166151        return $text;
    167152    }
    168    
     153
    169154    /**
    170155     *
     
    172157     * @return string
    173158     */
    174     function softsdev_product_shippings_update_footer( $text )
    175     {
     159    function softsdev_product_shippings_update_footer(  $text  ) {
    176160        if ( isset( $_GET['page'] ) && strpos( plugin_basename( wp_unslash( $_GET['page'] ) ), 'softsdev-product-shippings' ) === 0 ) {
    177161            $text = 'Version 2.4.1';
     
    179163        return $text;
    180164    }
    181    
     165
    182166    add_action( 'add_meta_boxes', 'wps_ship_meta_box_add', 50 );
    183     function wps_ship_meta_box_add()
    184     {
     167    function wps_ship_meta_box_add() {
    185168        add_meta_box(
    186169            'shippings',
     
    192175        );
    193176    }
    194    
     177
    195178    if ( !function_exists( 'wps_shipping_get_shippings_meta' ) ) {
    196         function wps_shipping_get_shippings_meta( $product_id )
    197         {
     179        function wps_shipping_get_shippings_meta(  $product_id  ) {
    198180            $shippings = get_post_meta( $product_id, 'shippings', true );
    199181            if ( !is_array( $shippings ) ) {
     
    202184            return $shippings;
    203185        }
    204    
     186
    205187    }
    206188    /**
     
    209191     * @global type $woocommerce
    210192     */
    211     function wps_shipping_form()
    212     {
    213         global  $post, $woocommerce ;
     193    function wps_shipping_form() {
     194        global $post, $woocommerce;
    214195        $productIds = get_option( 'woocommerce_product_apply_ship', array() );
    215196        $postshippings = wps_shipping_get_shippings_meta( $post->ID );
    216        
    217197        if ( is_array( $productIds ) ) {
    218198            foreach ( $productIds as $key => $product ) {
    219199                $shippings = wps_shipping_get_shippings_meta( $product );
    220200                if ( !get_post( $product ) || $shippings && !count( $shippings ) ) {
    221                     unset( $productIds[$key] );
     201                    unset($productIds[$key]);
    222202                }
    223203            }
    224204            $shippings = apply_filters( 'softsdev_shipping_method', $shippings );
    225205        }
    226        
    227206        update_option( 'woocommerce_product_apply_ship', $productIds );
    228207        $shipping_methods = $woocommerce->shipping->load_shipping_methods();
     
    235214        }
    236215        foreach ( $shippings as $ship ) {
    237            
    238216            if ( $ship->enabled === 'yes' ) {
    239217                $checked = '';
     
    243221                ?>
    244222                <input type="checkbox" <?php
    245                 echo  $checked ;
     223                echo $checked;
    246224                ?> value="<?php
    247                 echo  $ship->id ;
     225                echo $ship->id;
    248226                ?>" name="ship[]" id="ship_<?php
    249                 echo  $ship->id ;
     227                echo $ship->id;
    250228                ?>" />
    251229                <label for="ship_<?php
    252                 echo  $ship->id ;
     230                echo $ship->id;
    253231                ?>"><?php
    254                 echo  $ship->method_title ;
     232                echo $ship->method_title;
    255233                ?></label>
    256234                <br />
    257235            <?php
    258236            }
    259        
    260         }
    261     }
    262    
     237        }
     238    }
     239
    263240    add_action(
    264241        'save_post',
     
    273250     * @return type
    274251     */
    275     function wps_ship_meta_box_save( $post_id, $post )
    276     {
     252    function wps_ship_meta_box_save(  $post_id, $post  ) {
    277253        // Restrict to save for autosave
    278254        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE || isset( $_REQUEST['action'] ) && sanitize_title( $_REQUEST['action'] ) != 'editpost' ) {
     
    284260        }
    285261        delete_post_meta( $post_id, 'shippings' );
    286        
    287262        if ( get_post_type() === 'product' && isset( $_POST['ship'] ) ) {
    288263            $productIds = get_option( 'woocommerce_product_apply_ship' );
    289            
    290264            if ( is_array( $productIds ) && !in_array( $post_id, $productIds ) ) {
    291265                $productIds[] = $post_id;
    292266                update_option( 'woocommerce_product_apply_ship', $productIds );
    293267            }
    294            
    295268            //delete_post_meta($post_id, 'shippings');
    296269            $shippings = array();
     
    301274                }
    302275            }
    303            
    304276            if ( count( $shippings ) ) {
    305277                update_post_meta( $post_id, 'shippings', $shippings );
     
    307279                delete_post_meta( $post_id, 'shippings' );
    308280            }
    309        
    310         }
    311    
    312     }
    313    
     281        }
     282    }
     283
    314284    /**
    315285     *
     
    324294     * @return type
    325295     */
    326     function wps_shipping_method_disable_country( $packages )
    327     {
     296    function wps_shipping_method_disable_country(  $packages  ) {
    328297        foreach ( $packages as &$package ) {
    329298            $items = $package['contents'];
     
    334303            ) );
    335304            if ( is_array( $items ) ) {
    336                
    337305                if ( $softsdev_wps_plugin_settings['default_option_mp'] == 'common_only' ) {
    338306                    foreach ( $items as $item ) {
    339307                        $itemsShips = get_post_meta( $item['product_id'], 'shippings', true );
    340                        
    341308                        if ( is_string( $itemsShips ) ) {
    342309                            $ships[] = $itemsShips;
     
    344311                            $ships[] = array_values( $itemsShips );
    345312                        }
    346                    
    347313                    }
    348314                    $ships = softsdev_remove_empty_items( $ships );
    349                    
    350315                    if ( count( $ships ) > 1 ) {
    351316                        $ships_temp = $ships[0];
    352                         for ( $i = 1 ;  $i < count( $ships ) ;  $i++ ) {
     317                        for ($i = 1; $i < count( $ships ); $i++) {
    353318                            $ships_temp = array_intersect( $ships_temp, $ships[$i] );
    354319                        }
    355320                        $ships = $ships_temp;
    356321                    }
    357                
    358322                } else {
    359323                    foreach ( $items as $item ) {
    360324                        $itemsShips = get_post_meta( $item['product_id'], 'shippings', true );
    361                        
    362325                        if ( is_string( $itemsShips ) ) {
    363326                            $ships[] = $itemsShips;
     
    365328                            $ships = array_merge( $ships, $itemsShips );
    366329                        }
    367                        
    368330                        $ships = softsdev_remove_empty_items( $ships );
    369331                    }
    370332                }
    371            
    372333            }
    373334            //             echo '<pre>'; var_dump($ships); echo '</pre>';
    374            
    375335            if ( count( $ships ) > 0 ) {
    376336                $available_methods =& $package['rates'];
     
    383343                    foreach ( $available_methods as $key => $shipping ) {
    384344                        if ( !in_array( $shipping->method_id, $filtered_ship ) ) {
    385                             unset( $available_methods[$key] );
     345                            unset($available_methods[$key]);
    386346                        }
    387347                    }
     
    393353                //                     'default_option_mp' => 'expensive',
    394354                //                 ) );
    395                
    396355                if ( count( $available_methods ) > 0 && count( $ships ) > 1 && $softsdev_wps_plugin_settings['default_option_mp'] != 'let_customer_decide' && $softsdev_wps_plugin_settings['default_option_mp'] != 'common_only' ) {
    397356                    #if common ship not found
     
    420379                    foreach ( $available_methods as $_key => $_shipping ) {
    421380                        if ( !in_array( $_key, $aplicable_shipping ) ) {
    422                             unset( $available_methods[$_key] );
     381                            unset($available_methods[$_key]);
    423382                        }
    424383                    }
    425384                }
    426            
    427             }
    428        
     385            }
    429386        }
    430387        return $packages;
    431388    }
    432    
     389
    433390    // update new filter as depricated woocommerce_available_shipping_methods
    434391    add_filter( 'woocommerce_shipping_packages', 'wps_shipping_method_disable_country', 99 );
     
    439396     *
    440397     */
    441     function update_user_database()
    442     {
     398    function update_user_database() {
    443399        $is_shipping_updated = get_option( 'is_shipping_updated' );
    444        
    445400        if ( !$is_shipping_updated ) {
    446401            $args = array(
     
    452407            foreach ( $products as $pro_id ) {
    453408                $itemsShips = wps_shipping_get_shippings_meta( $pro_id );
    454                 if ( empty($itemsShips) ) {
     409                if ( empty( $itemsShips ) ) {
    455410                    delete_post_meta( $pro_id, 'shippings' );
    456411                }
     
    458413            update_option( 'is_shipping_updated', true );
    459414        }
    460    
    461     }
    462    
     415    }
     416
    463417    add_action( 'wp_head', 'update_user_database' );
    464418    add_action( 'admin_menu', 'softsdev_product_shippings_submenu_page' );
    465     function softsdev_product_shippings_submenu_page()
    466     {
     419    function softsdev_product_shippings_submenu_page() {
    467420        add_submenu_page(
    468421            'woocommerce',
     
    474427        );
    475428    }
    476    
    477     function softsdev_product_shippings_enqueue()
    478     {
     429
     430    function softsdev_product_shippings_enqueue() {
    479431        wp_enqueue_style( 'softsdev_product_shippings_enqueue', plugin_dir_url( __FILE__ ) . '/css/style.css' );
    480         wp_register_script( 'softsdev_product_shippings_setting_script', plugins_url( '/js/setting.js', __FILE__ ), array( 'jquery' ) );
     432        wp_register_script( 'softsdev_product_shippings_setting_script', plugins_url( '/js/setting.js', __FILE__ ), array('jquery') );
    481433        wp_enqueue_script( 'softsdev_product_shippings_setting_script' );
    482434        $data_to_pass = array(
     
    485437        wp_localize_script( 'softsdev_product_shippings_setting_script', 'dd_settings_data', $data_to_pass );
    486438    }
    487    
     439
    488440    add_action( 'admin_enqueue_scripts', 'softsdev_product_shippings_enqueue' );
    489441}
Note: See TracChangeset for help on using the changeset viewer.