ResolvedNeed pickup and delivery selector in header

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #33893

    Hello

    I need a pickup and delivery location selector in the header or footer for all pages. does theme lafka provide any shortcode or widget to add location selector in header or footer?

    #33896
    Althemist
    Keymaster

    Hi rashminpatel.cosmonautgroup,

    The selector is available inside the cart module on every page. Other than that, once you select a location and/or method, you can change it also on shop page, category pages, cart page and checkout page.

    #33905

    Hello

    My website link is as follows: –

    Home 6

    Theme has the functionality that once we select the location its display on following pages: –
    shop page, category pages, cart page and checkout page.

    Also shown in Screenshot link https://prnt.sc/hCPLDh3soUBM

    But we have client’s requirement that they wants this location box in all the pages. so they want us to keep it in Header or Footer.

    So can you explain me the way to keep this box in Header or Footer. Also, you can suggest the custom code for achieving this if its not possible from Admin Panel.

    #33916
    Alex
    Keymaster

    Hi,

    You can call the code for showing the box anywhere you like, but keep in mind that it was tested only for the intended locations mentioned above. So in some cases it may have unexpected behavior.
    So, for example, to show it right before the footer, you can use the following code:
    add_action('get_footer', array('Lafka_Branch_Locations', 'show_change_branch'), 1);

    You can hook it to different action, if you find one which better fits your needs.
    You can also call the function directly from any template you like, like this:
    Lafka_Branch_Locations::show_change_branch();

    Just be sure you are doing it from a template copied to the child theme, so you don’t loose your change.

    Regards,
    Alex

    #33929

    Thank you So Much, Alex.

    #37191
    swellboyvn
    Participant

    In your functions.php of the child theme add this code:

    function branches_shortcode() {
        ob_start(); // start output buffering
        
        // call the Lafka_Branch_Locations::show_change_branch() function
        add_action('get_footer', array('Lafka_Branch_Locations', 'show_change_branch'), 1);
        Lafka_Branch_Locations::show_change_branch();
        
        $output = ob_get_clean(); // get the buffered output
        return $output;
    }
    add_shortcode('branches', 'branches_shortcode');

    After that, you can display the branches picker anywhere with this block [branches].

    #37193
    swellboyvn
    Participant

    Small fix 🙂

    function branches_shortcode($atts) {
        $atts = shortcode_atts(array(
            'id' => '',
        ), $atts, 'branches');
        
        static $content = array(); // declare a static variable to store the content
        
        if (!isset($content[$atts['id']])) {
            ob_start(); // start output buffering
            
            Lafka_Branch_Locations::show_change_branch();
            
            $content[$atts['id']] = ob_get_clean(); // get the buffered output
        }
        
        return $content[$atts['id']];
    }
    add_shortcode('branches', 'branches_shortcode');
    
Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register