Non-blocking file_put_contents in function.php

Instead of contacting the remote site to get the information in an expensive HTTP request, why not have the remote site send you the data at regular intervals? Register a REST API endpoint to recieve the data on In that endpoint, take in the data and save it in all.json On the remote site add … Read more

Link product attribute value to a URL – woocommerce

With the current WooCommerce release, try this instead of the make_product_atts_linkable() function in the question: function make_product_atts_linkable( $text, $attribute, $values ) { $vals = array(); if ( $attribute->is_taxonomy() ) { foreach ( $attribute->get_options() as $i => $id ) { if ( $url = get_term_meta( $id, ‘attribute_url’, true ) ) { $vals[] = ‘<a href=”‘ . … Read more

Get custom field value from the function.php

Found a solution: add_filter( ‘facetwp_preload_url_vars’, function( $url_vars ) { //get the id of the current page $url=”http://” . $_SERVER[ ‘HTTP_HOST’ ] . $_SERVER[ ‘REQUEST_URI’ ]; $current_post_id = url_to_postid( $url ); //get the offer_type (custom field) from the current page id $offer_id = get_field(‘offer_type’, $current_post_id); //returns an id //get the taxonomy slug from the offer_id $term … Read more

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