Plugin Directory

Changeset 2583051


Ignore:
Timestamp:
08/15/2021 07:25:26 AM (5 years ago)
Author:
mulutuvn
Message:

1.1.2

Location:
mulutu/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • mulutu/trunk/MulutuWCFront.php

    r2579788 r2583051  
    88class MulutuWCFront {
    99
    10     function disableShippingCalcOnCart( $show_shipping ) {
     10    function disableShippingCalcOnCart( $showShipping ) {
    1111        if( is_cart() ) {
    1212            return false;
    1313        }
    14         return $show_shipping;
     14        return $showShipping;
    1515    }
    1616
     
    1919        unset($fields['billing']['billing_postcode']);
    2020
    21         $fields['billing']['billing_city']['class'] = array('d-none');
     21        $onlyVirtual = true;
     22        foreach( WC()->cart->get_cart() as $cartItem ) {
     23            if (!$cartItem['data']->is_virtual()) {
     24                $onlyVirtual = false;   
     25            }
     26        }
    2227
    23         $fields['billing']['billing_address_1'] = array(
    24             'class'        => array ('d-none'),
    25             'required'     => false
    26         );
    27 
    28         $fields['billing']['billing_address_1_text'] = array(
    29             'label'        => 'Địa chỉ',
    30             'placeholder'  => 'Địa chỉ',
    31             'class'        => array ('form-row', 'address-field', 'validate-required', 'form-row-wide'),
    32             'priority'     => 40,
    33             'required'     => true
    34         );
    35 
    36         $fields['billing']['billing_district'] = array(
    37             'type'       => 'select',
    38             'required'   => true,
    39             'priority'   => 40,
    40             'class'      => array( 'form-row', 'form-row-first', 'validate-required' ),
    41             'label'      => __( 'Quận / Huyện' ),
    42             'options'    => array(
    43                 -1     => __( 'Chọn quận huyện', 'Chọn quận huyện' )
    44             )
    45         );
    46 
    47         $fields['billing']['billing_ward'] = array(
    48             'type'       => 'select',
    49             'required'   => true,
    50             'priority'   => 40,
    51             'class'      => array( 'form-row', 'form-row-last', 'validate-required' ),
    52             'label'      => __( 'Phường / Xã' ),
    53             'options'    => array(
    54                 -1       => __( 'Chọn phường xã', 'Chọn phường xã' )
    55             )
    56         );
     28        if ($onlyVirtual) {
     29            unset($fields['billing']['billing_address_1']);
     30            unset($fields['billing']['billing_address_2']);
     31            unset($fields['billing']['billing_city']);
     32            unset($fields['billing']['billing_country']);
     33            unset($fields['billing']['billing_state']);
     34            add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );
     35        } else {
     36            $fields['billing']['billing_city']['class'] = array('d-none');
     37            $fields['billing']['billing_address_1'] = array(
     38                'class'        => array('d-none'),
     39                'required'     => false
     40            );
     41            $fields['billing']['billing_address_1_text'] = array(
     42                'label'        => 'Địa chỉ',
     43                'placeholder'  => 'Địa chỉ',
     44                'class'        => array ('form-row', 'address-field', 'validate-required', 'form-row-wide'),
     45                'priority'     => 41,
     46                'required'     => true
     47            );
     48            $fields['billing']['billing_district'] = array(
     49                'type'       => 'select',
     50                'required'   => true,
     51                'priority'   => 40,
     52                'class'      => array( 'form-row', 'form-row-first', 'validate-required' ),
     53                'label'      => __( 'Quận / Huyện' ),
     54                'options'    => array(
     55                    -1     => __( 'Chọn quận huyện', 'Chọn quận huyện' )
     56                )
     57            );
     58            $fields['billing']['billing_ward'] = array(
     59                'type'       => 'select',
     60                'required'   => true,
     61                'priority'   => 40,
     62                'class'      => array( 'form-row', 'form-row-last', 'validate-required' ),
     63                'label'      => __( 'Phường / Xã' ),
     64                'options'    => array(
     65                    -1       => __( 'Chọn phường xã', 'Chọn phường xã' )
     66                )
     67            );
     68        }
    5769
    5870        return $fields;
     
    120132        ));
    121133    }
    122 
    123134}
    124135
     
    126137
    127138////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     139/**
     140 * @todo Add Cart page support
     141 */
    128142add_filter('woocommerce_cart_ready_to_calc_shipping', array($objMulutuWCFront, 'disableShippingCalcOnCart'), 99);
    129143
     
    134148add_filter('woocommerce_checkout_fields', array($objMulutuWCFront, 'overrideCheckoutFields'));
    135149add_action('woocommerce_after_checkout_form', array($objMulutuWCFront, 'debounceAddJSScriptCheckout'));
     150add_filter('woocommerce_cart_needs_shipping_address', '__return_false');
  • mulutu/trunk/plugin.php

    r2579798 r2583051  
    99* Plugin URI: https://mulutu.vn/
    1010* Description: Plugin provides basic function for GHN Panel.
    11 * Version: 1.1.1
     11* Version: 1.1.2
    1212* Text Domain: mulutu
    1313* Author: Mulutu team
  • mulutu/trunk/readme.md

    r2579798 r2583051  
    3131
    3232### Changelog
     331.1.2
     34* Fix bug
     35* Support virtual products
    33361.1.1
    3437* Fix bug
  • mulutu/trunk/readme.txt

    r2579800 r2583051  
    55Tested up to: 5.8
    66Requires PHP: 5.6
    7 Stable tag: 1.1.1
     7Stable tag: 1.1.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3737
    3838== Changelog ==
     39= 1.1.2 =
     40* Fix bug
     41* Support virtual products
    3942
    4043= 1.1.1 =
Note: See TracChangeset for help on using the changeset viewer.