jeudi 22 septembre 2016

If before a certain hour block a day

I'm trying to trigger something in some code that was written for me but I cant seem to get it to work.

What I need is to have a date picker block out today and before today if its before 11am and block out tomorrow and before if its after 11am. I was trying to put an if/else on the minDate in the code below but no joy.

.jQuery(".dpicker").datepicker(
{
    minDate: 2,
    onSelect: function(dateText, inst)
    {
        var date = jQuery(this).val();
        jQuery('#frm_field_263_container').hide();
        jQuery('#frm_field_263_container').after(
            '<img id="loading" src="loading30.gif" />'
        );
        jQuery('#frm_field_265_container').hide();
        var qantity;
        if (!jQuery('#field_6pc0y').val())
        {
            qantity = 0;
        }
        else
        {
            qantity = parseInt(jQuery('#field_6pc0y').val());
        }
        jQuery.post(frm_js.ajax_url,
        {
            'action': 'order_quantity',
            'pick_up_date': jQuery('#field_mv0ti').val(),
            'product_id': jQuery('#product_id').val(),
            'product_title': jQuery('#product_title').val()
        }, function(response)
        {
            stock = parseInt(response);
            jQuery('#field_navpp').val(response - qantity);
            jQuery('#loading').hide();
            jQuery('#frm_field_263_container').show();
            if (response - qantity < 0)
            {
                jQuery('#frm_field_265_container').show();
            }
        });
    },
    dateFormat: 'yy-mm-dd',
    changeMonth: true,
    changeYear: true
});

Aucun commentaire:

Enregistrer un commentaire