Skip to content

Instantly share code, notes, and snippets.

@createit-dev
createit-dev / functions.php
Last active November 17, 2023 11:43
"Live Visitor Count" feature using Server-Sent Events (SSE) in a WooCommerce
<?php
/**
* "Live Visitor Count" feature using Server-Sent Events (SSE) in a WooCommerce
* Display a live count of how many users are currently viewing a particular product.
*/
add_action('rest_api_init', 'register_api_routes');
function register_api_routes()
{
@createit-dev
createit-dev / functions.php
Last active November 15, 2023 12:18
Calculating WooCommerce Shipping Costs - WooCode Tips Series
<?php
/**
* Calculate Shipping Costs Programmatically in WooCommerce
* - fetch standard methods
* - integrate with Flexible-shipping Plugin
*/
function ct_get_available_shipping_methods_for_customer_cart($country_code = 'PL') {
if (function_exists('WC')) {