ResolvedNeed pickup and delivery selector in header
Tagged: LAFKA-THEME
- This topic has 6 replies, 4 voices, and was last updated 2 months, 1 week ago by
swellboyvn.
- AuthorPosts
- May 24, 2022 at 1:12 pm #33893
rashminpatel.cosmonautgroup
ParticipantHello
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?
May 25, 2022 at 10:51 am #33896Althemist
KeymasterHi 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.
May 26, 2022 at 9:17 am #33905rashminpatel.cosmonautgroup
ParticipantHello
My website link is as follows: –
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.
May 26, 2022 at 11:36 am #33916Alex
KeymasterHi,
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,
AlexMay 26, 2022 at 12:44 pm #33929rashminpatel.cosmonautgroup
ParticipantThank you So Much, Alex.
March 30, 2023 at 11:19 am #37191swellboyvn
ParticipantIn 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].
March 30, 2023 at 12:25 pm #37193swellboyvn
ParticipantSmall 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');
- AuthorPosts
You must be logged in and have valid license to reply to this topic.