Replace Woocommerce “add to cart” to be “Download” button [closed]

hook into the woocommerce hook is_purchasable add_filter(“woocommerce_is_purchasable”, function($product, $isPurchasable) { if(!$isPurchasable) return $isPurchasable; $productId = $product->get_id(); $user = wp_get_current_user(); if($user->exists() && $productId == 769) { $userId = $user->ID; $userEmail = $user->user_email; if(wc_customer_bought_product($userEmail, $userId, $productId)) { //block the purchase so the user sees read more instead of add to cart $isPurchasable = false; } } return … Read more

Deprecated: Function create_function() is deprecated [closed]

Your server runs with a PHP version that doesn’t support create_function. From the PHP manual about create function Warning This function has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0. Relying on this function is highly discouraged. If you are using PHP 5.3.0 or newer a native anonymous function should be … Read more

Hide HTML element (by class or ID) with PHP

As per our discussion in the comments, all you really need to do is .remove() the element. The following is the approach I’d take. First I’d check to make sure the element exists before attempting to remove it. If it’s there, then run jQuery’s .remove(). if( $( ‘#elementID’ ).length > 0 ) { $( ‘#elementID’ … Read more

How to use html inside a functions.php code?

function misha_loadmore_ajax_handler() { $args = json_decode ( stripslashes ( $_POST[ ‘query’ ] ), true ); $args[ ‘paged’ ] = $_POST[ ‘page’ ] + 1; $args[ ‘post_status’ ] = ‘publish’; query_posts ( $args ); if( have_posts () ) :while ( have_posts () ): the_post (); ?> <div class=”griditem”> <a class=”producturl” href=”<?php the_permalink (); ?>”> <div class=”productimagewrapper”> … Read more

How to check if the current page is at a specified path in the URL?

You could try this instead if (!is_front_page() && is_home()) { get_template_part(‘template-parts/blog-categories’); } Explanation for the difference between front_page an home is here: https://wordpress.stackexchange.com/a/239838 if you set a page as a blog-page it is “home”, in your case the landing-page is the so called “front_page”. This is WordPress specific.

Search WordPress using static html page

If you want to submit a form you need a <form> element to contain the input. (You can get away without one but you’d need script to fake the submit.) The action is the homepage with the search text in an input named ‘s’, e.g. <form method=”get” action=”https://example.com/”> <input type=”search” name=”s” /> <input type=”submit” value=”Search” … Read more