Tag Info

New answers tagged

0

It turns out I just needed to return the $title variable which already had what I needed: function woocommerce_endpoint_titles( $title ) { $sep = ' | '; $sitetitle = get_bloginfo(); if ( is_wc_endpoint_url( 'view-order' ) ) { $title = 'View Order: ' . $sep . $sitetitle; } if ( is_wc_endpoint_url( 'edit-account' ) ) { ...


0

You need to explode the comma separated string to get the array of IDs. Follow the below code. $cookie_array = $_COOKIE["your-results"]; // Test output echo $cookie_array; $cookie_array = array_map( 'absint', (array) explode(',', $cookie_array) ); $sug_args = array( 'post_type' => 'product', 'post__in' => $cookie_array, ); ...


0

Try this code. $handle=new WC_Product_Variable('12'); $variations1=$handle->get_children(); foreach ($variations1 as $value) { $single_variation=new WC_Product_Variation($value); echo '<option value="'.$value.'">'.implode(" / ", ...


0

I was able to do this a while back by following this WooCommerce tutorial: There may come a time where you would like change the text displayed on a product's page when it is In Stock or Out of Stock. Simply add the following code to the 'custom functions' area of your functions.php file: /** * Change In Stock / Out of Stock Text */ ...


0

content-single-product.php sounds like a woocommerce template, which is located here wp-content/plugins/woocommerce/templates. You can override this template in your theme or child them by creating a file wp-content/themes/your-theme/woocommerce/content-single-product.php.


0

Using the [woocommerce_my_account] shortcode, a user will see their account details if they're logged in and if they're not logged in, they'll see a login and registration form. Using the same page title "My Account" for these different users isn't ideal because a user that has never created an account won't naturally navigate to a "My Account" page in ...


0

This is not a casual task, nor do I think will you be able to find a free plugin to do that for you. How are your PHP skills? If not so much (and based on the casual way you've asked the question) I'm assuming they are zero, you will need to write up a specification for what you want, then pay a developer to create the product for you.


0

Looking at the function update_woocommerce_term_meta(), you would recognize it just uses the wordpress function update_metadata(), which essentially means that woocommerce is using meta values, just like you do in you CPT. With this in mind, I wouldn't think this procedure would slow down your site + your keeping compatibility by using existing functions. ...


0

If you're using WooCommerce, they have a shortcode that displays the logged in user's account details on a front end page: [woocommerce_my_account]


0

Okay, for anyone looking to include the WooCommerce review tab not on an actual single-product page here's the secret sauce: In your template file, you need: global $withcomments; $withcomments = true; Then add a filter for the comments template: //add filter to use our custom review template add_filter('comments_template','{{YOUR_HELPER_FUNCTION}}'); ...


0

You can use the following function and filter hook function filter_woo_cart_quantity($output, $cart_item, $cart_item_key){ return '<span class="quantity">' . sprintf( '%s &times; Quote', $cart_item['quantity'] ) . '</span>'; } add_filter('woocommerce_widget_cart_item_quantity','filter_woo_cart_quantity',10, 3);


0

OK I HAVE ALREADY!! yuuhuuu! Thanks a lot guys!! I have this: $args = array ( 'post_type' => 'product', 'posts_per_page' => -1, 'meta_query' => array( array( 'value' => 'demo', 'compare' => 'like' ), ), ); With this works atleast for me Thanks thanks!! Best regards!


0

You have written key as meta_value. It should be your meta name. The name you have given to your custom fields or meta. Then use the following query. $args = array ( 'post_type' => 'your-post-type', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'demo', ...


0

try something like this $args = array( "post_type" => "product", "meta_query" => array( array( "key" => "demo", "value" => "abc", "compare" => "EXISTS", ), ), ); $query = new WP_Query( $args );


0

You can use Enable stock management at product level from Product data > Inventory during adding a product and add you available stock amount e.g 1000 ( meter ). So customer can choose their amount and you can also get your exact amount of order.


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 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, ...


0

with your code, you have this : +++++++++++++++++++++++++++++++++++++++++++++++++++ attribute_color = C1 attribute_fabric = F1 attribute_fabric = F2 +++++++++++++++++++++++++++++++++++++++++++++++++++ attribute_color = C2 attribute_fabric = F1 attribute_fabric = F2 +++++++++++++++++++++++++++++++++++++++++++++++++++ attribute_fabric = ...


0

It is not advisable to run anything but the latest wordpress, especially with regards to security fixes. For a minior wordpress release, you can read the release notes and see if any of the changes are security related. If they aren't, then you can probably safely wait until the next security fix. In my experience, wordpress updates only sometimes break a ...


0

Hello @Wisdmlabs Thank you for your help. I have found this to work very well incase anyone else is wondering how to do so. <?php $taxonomyName = "product_cat"; $prod_categories = get_terms($taxonomyName, array( 'orderby'=> 'name', 'order' => 'ASC', 'hide_empty' => 1 )); foreach( ...


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

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() { ...


0

You can rewrite you code as <title> <?php if (!function_exists( 'is_product_category' )) { if( is_product_category( 'cds' ) ) { ?> CD <?php } elseif ( is_product_category( 'dvds' ) ) {?> DVD <?php } }else { wp_title( '|', true, 'right' ); } ?>


0

You can try the following code to check whether a category with a name exist of not $search_category_name="T-shirts"; //This gets top layer terms only. This is done by setting parent to 0. $parent_terms = get_terms('product_cat', array('orderby' => 'slug', 'hide_empty' => false)); foreach ($parent_terms as $pterm) { //check whether ...


0

WooCommerce provides these kind of functionality. Some of the links which you can use as a reference WooCommerce Product Search


0

Tried your code and its perfect but the changes you are trying to make needs to be added to a correct file. For your code to work you need to place it in your current theme's functions.php add_action( 'woocommerce_before_checkout_form', 'add_checkout_notice', 11 ); function add_checkout_notice() { wc_print_notice( __( 'A notice message instead.', ...


0

Query: Where extactly do you want this hidden fields to be placed? in single product page/Shop page/Archive page or any other. As per your request have tried some code and it gives me the result i.e the values for manage stock , stock and visiblity. The code is as follows global $woocommerce; $product=new WC_Product(get_the_ID()); echo ...


0

Wordpress provide the facility of using the custom user table but there isn't a way to get posts that to only post_type which are product. A good news may be that with custom work almost anything is possible. :) You may even look into using the REST API that's been added as of 2.1. With that you can currently read information from all of your stores. So ...


0

Have tried your code and it works fine and infact it also gives out the details of each product in the orders. The code which i tried $filters = array( 'post_status' => 'any', 'post_type' => 'shop_order', 'posts_per_page' => 200, 'paged' => 1, 'orderby' => 'modified', 'order' => 'ASC' ); $loop = new ...


0

Here is a reference link which you can use to try out customization in your code Let me know if this works for you in any way.


0

Have did some customization. This will help you show parent and child category images. You can later customize this code as per your requirements. $taxonomyName = "product_cat"; //This gets top layer terms only. This is done by setting parent to 0. $parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'slug', ...


0

Go to your child theme folder. Find woccomerce > emails from here you can edit your email template. Refer this link this will might be helpful


0

The correct method for generating a payment URL is: get_checkout_payment_url() So my code changed to to: $payment_page = $order->get_checkout_payment_url(); Which generates the following URL: http://www.example.co.za/checkout/order-pay/[order-number]?pay_for_order=true&key=order_[order-key] Which is what I was looking for. Note that the ...


0

The issue has been solved. See below for the correct code to display ACF multiple taxonomy links on WooCommerce product category archives. Specifically note the string: $related_terms = get_field('quick_links', $taxonomy . '_' . $term_id); $queried_object = get_queried_object(); $taxonomy = $queried_object->taxonomy; $term_id = ...


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 ...


0

After doing some research on google and woocommerce code i found the ans of the what i what. i have use following function for to send the mail to the user once order have been generated using the custom code in wordpress woo-commerce. WC()->mailer()->emails['WC_Email_Customer_Processing_Order']->trigger($orderId);


0

Try this - global $product; $categories = get_the_terms( $product->id, 'product_cat' ); and $categories will give you list of all the categories then you can check for a specific category - if(isset($categories["Test"])){ //do something } For your example - add_action( 'woocommerce_single_product_summary', 'wc_product_sold_count', 11 ); ...


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

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 ...


0

You can use the http://www.woothemes.com/products/advanced-notifications/ plugin for to manage woocommerce notifications.


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 ( ...


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', ...


0

The Correct syntax for writing a add_filter // Define the woocommerce_short_description callback function filter_woocommerce_short_description( $post_excerpt ) { // make filter magic happen here... return $post_excerpt; }; // add the filter add_filter( 'woocommerce_short_description',filter_woocommerce_short_description',10, 1 ); Your code ...


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' );


0

I would reverse engineer the User Switching plugin and then create a solution that works for you. Fortunately there is not a whole lot of work to do. Most of the crucial functionality is in this function: function switch_to_user( $user_id, $remember = false, $set_old_user = true ) { if ( ! $user = get_userdata( $user_id ) ) { return false; } ...


0

You just need to do a RIGHT JOIN to query the rows that have NULL values


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 ...



Top 50 recent answers are included