Adding discount functionality to the cart

after quite some headbanging I managed to make it somehow to work. Here is my code: add_action( ‘woocommerce_cart_calculate_fees’, ‘iom_add_custom_discount’, 10, 1 ); function iom_add_custom_discount( $wc_cart ){ $discount = 0; $product_ids = array(); $product_ids_disc = array(); $item_prices = array(); $in_cart = false; foreach ( $wc_cart->get_cart() as $cart_item_key => $cart_item ) { $cart_product = $cart_item[‘data’]; // here … Read more

Display a number value from mysql query in WP

Your easiest route to this is probably shortcodes, which effectively allow you to insert the output from a bit of PHP code in a post or page. For example, this would create the shortcode [countpeople] which you could pop in any post and it would render the value from the SQL statement using a $wpdb … Read more