mercredi 30 décembre 2015

enqueue css in a wordpress plugin condition

i have found a bug in a wordpress plugin http://ift.tt/1QZ9AQq

in checkout page if the option "Added possibility to make EU VAT field compulsory when the customer enters a company name." of plugin setting is active ,when click on buy product the color of field is green also when is empty, but in normal condition is red.

so i tried to load a custom css when the field vat is empty.

i have found the condition at line 1157 in a file called src/plugin-main.php http://ift.tt/1UgZgAL

so for load a custom js/css i build the code in /* start my code*/

// If VAT Number is required, but it was not entered or it's not valid,
        // display the appropriate error message and stop the checkout
        if($this->is_eu_vat_number_required($customer_country) &&
             ($this->vat_number_validated != Definitions::VAT_NUMBER_VALIDATION_VALID)) {



/* start my code*/

function wpb_adding_scripts() {
wp_register_script('my_amazing_script','http://ift.tt/1QZ9AQs', array('jquery'),'1.1', true);
wp_enqueue_script('my_amazing_script');
}

add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' );  

/* end my code*/


            $error = sprintf(__('You must enter a valid EU VAT number to complete the purchase.', 'wc-aelia-eu-vat-assistant'), $vat_number);
            $this->add_woocommerce_error($error);
            return;
        }

but not load never script/css in page , i tried my /* start my code*/ in function.php of my theme and the code work.

in this image you can show the bug http://ift.tt/1UgZjfS



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire