I just wrote this post about getting the minicart from Webstore to show (with cart content intact). Now I’m thinking, using similar methods, what other features of Webstore can I bring into a WordPress theme? For instance, to get the Webstore menu – can I just copy menu.tpl.php into a WordPress theme file named menu.php and then call it with get_template_part(‘menu’);? Would surely be a lot easier than how I currently do it using code I wrote relying on Simple HTML Dom to get the menu! And I wouldn’t get chastised by snotty programmers about SHD using file_get_contents! Ha.
Anyway, I’ll let you know how it goes. But to me, this is very exciting. No doubt if the experiments work out super fast & easy Webstore & WordPress customizations will be possible for practically every project.
Update For the Update:
Sooo, experimenting didn’t go very far. Seems requiring prepend.inc.php is able to get the cart
– probably because at the top of minicart.tpl.php there’s this neat code:
[php] $cart = Cart::get_cart();
$items = $cart->GetCartItemArray(); [/php]
but if you need more you’d have to require webstore index.php. Because it loads the functions for the category menu. I think. Experimenting doing just that however led to an error that read: Template file is missing. Because of course webstore’s index.php was trying to find various template files (like index.tpl.php) in WordPress which I’ve got installed in the root. Webstore is installed in /shop. When I have more time to fool around with this I’ll have time to move WordPress into a sub-directory of the webstore location – like /shop/wordpress… The good news about all of this is that it seems as if the outlook is good. I couldn’t successfully get the webstore menu to show up in my WordPress theme by using get_template_part(‘webstore-menu’); which of course was just a copy of menu.tpl.php…
But I also didn’t run into any PHP errors. Makes me think that if everything is in the right order and place t might work out. One day. I’ll beat this one day!
Happy coding.
Legacy Code Notice
Don’t use:
[php] $cart = Cart::get_cart();
[/php]
Do use:
[php] $cart = Cart::GetCart();
[/php]
get_cart(); can get the cart but it will fill your error logs with statements about using legacy code.