Forum Replies Created

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter Kasp

    (@kasp)

    PS: The missing image from the first post: https://pasteall.org/pic/show.php?id=097f257a85f091df99bd93082802b97f

    • This reply was modified 6 years, 3 months ago by Kasp.
    Thread Starter Kasp

    (@kasp)

    Okay, the woocommerce_shipping_methods hook is what we are using to load our custom shipping methods. I thought maybe we are simply somehow overriding the default shipping methods with our custom ones.

    I went to our custom shipping methods plugin’s code and checked what’s there:

    function add_custom_shipping_methods($methods) {
        return SmartieShipping::gI()->allShippingMethods();
    }
     
    add_filter( 'woocommerce_shipping_methods', 'add_custom_shipping_methods' );

    I realized the $methods argument contains an array of default shipping methods loaded before this hook and any custom shipping methods are supposed to be attached to this array.

    Perhaps someone somewhen changed this to return just our custom shipping methods from allShippingMethods().

    Changing the return line to the following made the default shipping methods available again:
    return array_merge($methods, SmartieShipping::gI()->allShippingMethods());

    This problem is now resolved.

    Thread Starter Kasp

    (@kasp)

    Hm nope, the default shipping methods are hardcoded in WC::get_shipping_method_class_names() and this one is called AFTER the above.

    In WC::get_shipping_method_class_names() the $shipping_methods array contains the default shipping methods before the return. But it seems like in WC::load_shipping_methods() the return value of WC::get_shipping_method_class_names() does not contain the default shipping methods anymore, just our custom ones.

    So perhaps the default shipping methods are lost somewhere in: apply_filters( 'woocommerce_shipping_methods', $shipping_methods )

    • This reply was modified 6 years, 3 months ago by Kasp.
    Thread Starter Kasp

    (@kasp)

    It seems like there’s a problem with WC::load_shipping_methods(), because it expects a $package = array() argument and then there’s a condition:

    if ( ! empty( $package ) ) {
        // ...
    } else {
        $this->shipping_methods = array();
    }

    Because WC()->shipping->load_shipping_methods() is called without argument, the default shipping methods get always erased from the array within the else block.

    Location: WC::load_shipping_methods() in /wp-content/plugins/woocommerce/includes/class-wc-shipping.php at 152

    Thread Starter Kasp

    (@kasp)

    It seems like this part, which generates the dropdown items:

    foreach ( WC()->shipping->load_shipping_methods() as $method ) {
        if ( ! $method->supports( 'shipping-zones' ) ) {
          continue;
        }
        echo '<option data-description="' . esc_attr( wp_kses_post( wpautop( $method->get_method_description() ) ) ) . '" value="' . esc_attr( $method->id ) . '">' . esc_attr( $method->get_method_title() ) . '</li>';
    }

    …does only get the custom shipping methods from WC()->shipping->load_shipping_methods(), no Flat Rate, Free Shipping or Local Pickup is in the returned array.

    To make this work, I changed the line 668 in service/class-em-event.php to:

    $filter_results[]= $event_dao->get_events_at_date($start_date,true);

    And I have added this method to dao/class-em-event.php:

        // Get events at a date
        public function get_events_at_date($date, $format = false) {
            
            $start_time = em_time($date);
            $end_time = $start_time + 86340;
            
            $event_ids = array();
            $filter = array(
                'orderby' => 'date',
                 'numberposts'=> -1,
                'post_status'=> 'publish',
                'order' => 'DESC',
                'meta_query' => array(// WordPress has all the results, now, return only the events after today's date
                   'relation' => 'AND', 
                    array(
                        'key' => em_append_meta_key('start_date'), // Check the start date field
                        'value' => $start_time, // Set today's date (note the similar format)
                        'compare' => '>=', // Return the ones greater than today's date
                        'type' => 'NUMERIC,' // Let WordPress know we're working with numbers
                    ),
                    array(
                        'key' => em_append_meta_key('start_date'), // Check the start date field
                        'value' => $end_time, // Set today's date (note the similar format)
                        'compare' => '<=', // Return the ones greater than today's date
                        'type' => 'NUMERIC,' // Let WordPress know we're working with numbers
                    )
                ),
                'post_type' => EM_EVENT_POST_TYPE);
    
            $events = $this->get_events($filter);
            
            if (!empty($events)):
                foreach ($events as $event):
                    $event_ids[] = $event->ID;
                endforeach;
            endif;
            
            $recurring_events= $this->get_recurring_events_by_date($date);
            $event_ids= array_merge($event_ids,$recurring_events->ids);
          
            return $event_ids;
        }
    • This reply was modified 7 years, 5 months ago by Kasp.
    Thread Starter Kasp

    (@kasp)

    I’ved checked the topics thanks. I suppose there is no way to add fancy anchors like #contact as of now. Might be a feature to consider.

    Thank you very much for this theme and for your help! ??

    Thread Starter Kasp

    (@kasp)

    Thanks for the plugin ??

    I need to anchor the links first through. Any idea about that? ??

    Thread Starter Kasp

    (@kasp)

    Everything works great now. Thank you very much guys. ??

    Thread Starter Kasp

    (@kasp)

    Okay, sounds great. Is there any estimation when could it be?

    Thread Starter Kasp

    (@kasp)

    That worked. Thank you very much!

    Really there seem to be several UI issues in the backend with the latest WP version, at least in Chrome.

Viewing 12 replies - 1 through 12 (of 12 total)