Is there a way to check if the shopping cart is empty? I have an integration with wordpress and i want to display my simple custom "Cart" button on the page only it there are some items in the cart already..
You can do this only if you are able to include ammeber's bootstrap: PHP: include "/amember/bootstrap.php";$cart = Am_Di::getInstance()->session->cart;if($cart && $cart->getItems()){// Cart have items;}
Hmm... im using this in Wordpress(Catalyst hooks) so i tried this (which i think is bootstrap.php equivalent..) $cart = am4PluginsManager::getAPI()->session->cart; print_r($cart); And nothing gets printed..
I tied to include bootstrap.php into wordpress (in functions.php) and i get this error: "Script Error An internal error happened in the script, please contact webmaster for details" Maybe some conflict with Am_Lite ? Is there a way to access the session directly?
No you can't access session directly. cart is an object so cart class must be defined before you will be able to load it from session. Try to move bootstrap.php include before any output Error can be generated if you place it after html code (amember will be unable to start session then)
I know that there is a plugin for wordpress that works with cart. So there must be a way to access the session somehow. I tried to hook the bootstrap.php in Catalyst custom-functions.php and created a hook: //include za bootstrap for cart session check add_action('init', 'process_amember_session'); function process_amember_session(){ include_once ("/home/trusteds/public_html/amember/bootstrap.php"); } ...and this works if im on /amember/... sites(with head and footer generated from WP Catalyst), but as soon as i get back to "normal" wordpress sites(like the domain root) i get the error message.