Tag Info

Hot answers tagged

2

If you define your own empty function, then it can cause a problem when the plugin tries to load its same function. The simplest way around this is to use PHP's built-in function_exists() method wrapped around the function call. If that function is defined (like inside the plugin) it'll run the call. If not, it's skips over it without a second thought. if ( ...


2

This is not that complicated, here is a code snippet that will get you started: if(is_user_logged_in()) { //We only need these products to check $products_to_check = array(81,82,83,84); $customer_bought = array(); //Get all orders made by the current user in the last 365 days $customer_orders = get_posts( apply_filters( ...


1

I don't think you'll be able to pull this off directly. All of the admin screens, objects and hooks are tied to the "product" post type. What you should probably do is add a new product type (a sister to the simple/variable product types). This new product type could be called "Custom_Type". You can then add a field that lets you point to one of your custom ...


1

I'm not completely sure that you do actually need get_terms() twice. It looks very ineffecient and overboard. I don't know if you need this for ordering purposes, but still, there are better ways of doing this without hitting the db so hard. One alternative is to make one call to get_terms() and then use usort() to sort your terms by parent. But this is ...


1

You need to add your class of fi-shopping-cart to both instances of the cart link element: In the shorter, single-line snippet you've used your theme file, and in the the custom code you added to your functions.php file. If the custom class is present in only one snippet, it will be replaced when the other is loaded in. The updated code is below. After ...


1

The code for changing the default image is provided by WooCommerce in this link but for your requirement we have to customize the code as follows /* * goes in theme functions.php or a custom plugin. Replace the image filename/path with your own :) * **/ add_action('init', 'custom_fix_thumbnail'); function custom_fix_thumbnail() { ...


1

You need to use the woocommerce_get_price filter: add_filter('woocommerce_get_price', 'return_custom_price', $product, 2); function return_custom_price($price, $product) { global $post, $woocommerce; // Array containing country codes $county = array('CH'); // Amount to increase by $amount = 5; // If the custromers shipping ...


1

I found a solution with a recursive function function decomposePrice($base, $iValue, $values, $prices) { $d = array(); foreach ($prices as $i => $p) { $baseP = "$base{$values[$iValue][$i]}|"; if (!is_array($p)) { $d[$baseP] = $p; } else { $d = array_merge($d, decomposePrice($baseP, $iValue + 1, ...


1

I found the answer - might be obscure, but still might help someone: Apparently the custom navigation template messed up / overwrote the "$posts" array, so I just saved the original, and restored it after including the navigation: <?php $saved_posts = $posts; get_template_part('tpl-nav'); $posts = $saved_posts; ?> Just added to to the top of the ...


1

So... I was working on another section of the site and was browsing the Foundation Docs. I saw the ability to push/pull columns and decided to give it a try. It worked. Here's the code I used: <li <?php post_class( $classes ); ?>> <?php do_action( 'woocommerce_before_shop_loop_item' ); ?> <div class="row"> <a ...


1

Use pre_get_posts to modify author archive queries- function wpd_author_archive( $query ){ if ( $query->is_author() && $query->is_main_query() ){ $query->set( 'post_type', array( 'post', 'product' ) ); } } add_action( 'pre_get_posts', 'wpd_author_archive' );


1

There is a similar question on StackOverflow, check the answer there. Hope this will help you. Here is the code you can use: add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); function custom_override_checkout_fields( $fields ) { $fields['shipping']['custom_field'] = array( 'label' => 'Custom field', ...



Only top voted, non community-wiki answers of a minimum length are eligible