0

I am trying to enque a css file thorugh my child themes functions.php after a specific plugin css file with the handle openpos.bill.bootstrap. Unfortunately the current code does not load anything. Any idea how to solve this problem?

Plugin uses the following code block to load styles

public function initScripts(){
    global $op_in_pos_screen;
    global $op_in_bill_screen;
    global $op_in_kitchen_screen;
    if($op_in_pos_screen)
    {
        add_action( 'init', array($this,'registerScripts') ,10 );
    }
    if($op_in_bill_screen)
    {
        add_action( 'init', array($this,'registerBillScripts') ,10 );
    }
    if($op_in_kitchen_screen)
    {
        add_action( 'init', array($this,'registerKitchenScripts') ,10 );
    }
    add_filter('script_loader_tag',  array($this,'add_async_attribute'), 10, 2);
}

public function registerBillScripts(){
    $info = $this->_core->getPluginInfo();

    wp_enqueue_style('openpos.bill.bootstrap', OPENPOS_URL.'/assets/css/bootstrap.css') // load my custom css after this one

    // ... and so on

}

My code to load my custom style.css file which fails to load anything

function load_custom_css_to_style_billing_screen() {
    wp_enqueue_style('bill-screen-style', get_stylesheet_directory_uri() . '/include-parts-from-functions-php-file/frontend-related/plugins/openpos-plugin/pos-app/css/bill-screen-style.css',array('openpos.bill.bootstrap'));
    }
add_action( 'wp_enqueue_scripts', 'load_custom_css_to_style_billing_screen', 10 );

1 Answer 1

0

The original stylesheet is enqueued as openpos.bill.bootstrap

wp_enqueue_style('openpos.bill.bootstrap', OPENPOS_URL.'/assets/css/bootstrap.css') // load my custom css after this one

But you've set openpos.bill.style as the dependency:

wp_enqueue_style('bill-screen-style', get_stylesheet_directory_uri() . '/include-parts-from-functions-php-file/frontend-related/plugins/openpos-plugin/pos-app/css/bill-screen-style.css',array('openpos.bill.style'));

These need to be the same.

1
  • changed it to the right handle but it does not work...
    – evavienna
    Mar 25, 2021 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.