Created
September 12, 2019 02:48
-
-
Save growdev/20d7f61d870e7cf9746a81025f5f94e7 to your computer and use it in GitHub Desktop.
Quick plugin to show items that are in WooCommerce cart.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Show Cart | |
* Plugin URI: https://growdevelopment.com | |
* Description: Show the cart contents | |
* Version: 1.0.0 | |
* Author: Grow Development | |
*/ | |
function growdev_cart(){ | |
?><style> | |
.growdev-cart-box{ | |
width: 500px; | |
height: 80px; | |
position: absolute; | |
bottom:10px; | |
right: 10px; | |
background: grey; | |
z-index: 99999; | |
} | |
</style> | |
<div class="growdev-cart-box"> | |
<p> | |
<?php | |
$cookie = WC()->session->get_session_cookie(); | |
echo "WC Cookie: " . $cookie[0] . '</br>'; | |
echo "popup_product_added_cart_key: " . WC()->session->get('popup_product_added_cart_key' ); | |
?> | |
</p> | |
<ol> | |
<?php | |
foreach ( WC()->cart->cart_contents as $cart_item_key => $cart_item ) { | |
echo "<li>(" . $cart_item_key . "): " . $cart_item['data']->get_name() . "</li>"; | |
} | |
?> | |
</ol> | |
</div> | |
<?php | |
} | |
add_action('wp_footer', 'growdev_cart', 50); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment