New answers tagged

0

While not trying to be subjective or biased, you should know that Woocommerce was not designed to do this out-of-the-box. Could you adapt Woocommerce to act this way? The short answer is maybe but you may not like doing it. The biggest problem I have had is that the to-go orders are emailed too slowly. Sometimes the customer arrives before the order email ...


0

Here's my code for creating a subscription -- it took a lot of trial and error to figure it all out. Best of luck! function create_test_sub() { $email = 'test@test.com'; $start_date = '2015-01-01 00:00:00'; $address = array( 'first_name' => 'Jeremy', 'last_name' => 'Test', 'company' => '', 'email' ...


0

Btw, as for all custom themes designed from scratch: do not forget to include wp_head() and wp_footer() functions as they are needed to let woocommerce automatically link the necessary js-files. Those js-files are needed to make the woo do it's thing. I just ran into this issue coding a theme from scratch and accidently deleting wp_footer().


0

You could just use a plugin such as CDN Enabler which will change the URL of all your static files to point to the CDN URL. This works for all your images, CSS/JS files, etc.


-1

What about $coupon->customer_email; ?


0

WooCommerce product is just a custom post type. You can use get_posts or WP_Query.


0

WooCommerce uses a single hook to display many things and just changing the hook priorities change the order of elements. Just change the hook and their order to achieve your goal. add_action( 'woocommerce_single_product_summary', 'my_add_product_cat', 6); add_action( 'woocommerce_shop_loop_item_title', 'my_add_product_cat', 11); I have given ...


0

Hook the woocommerce_currency filter. function change_woocommerce_currency( $currency ) { if ( is_product_category( 'my-special-cat' ) ) { $currency = 'myCred' // or whatever the currency symbol is } return $currency; } add_filter( 'woocommerce_currency', 'change_woocommerce_currency' );


0

To check if woocommerce or anyother plguin is active, paste the following code on the template where you want to display the message. if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { echo 'WooCommerce is active.'; } else { echo 'WooCommerce is not Active.'; }


1

It is all fine. You just need to declare variable global first then you can set the value of this and access globally. function my_free_shipping( $is_available ) { global $woocommerce, $product_notfree_ship; // set the product ids that are $product_notfree_ship $product_notfree_ship = array( '1', '2', '3', '4', '5' ); Then again declare it globally when ...


0

Declare it as global $product_notfree_ship as you are doing, just access it via this $GLOBALS['product_notfree_ship'];


0

Just loop over WP_Query::$posts to get the titles: $option_posts = new WP_Query( [ 'post_type' => 'organisationer' ] ); $options = []; foreach ( $option_posts->posts as $post ) { $key = "option_{$post->ID}"; $options[ $key ] = apply_filters( 'the_title', $post->post_title ); } woocommerce_form_field_radio( 'custom_field', ...


0

Managed to solve my own issue. Simply paste the following into functions.php function custom_wc_ajax_variation_threshold( $qty, $product ) { return 10; } add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 ); Then change the 'return 10;' to however many variations you have. Please note this may slow ...


0

The key is to pass arguments to the callback function. Try this: /* Function that returns custom product hyperlink */ function wc_cart_item_name_hyperlink( $link_text, $product_data ) { $title = get_the_title($product_data['product_id']); return sprintf( '<a href="%s">%s </a>','example.com/mypage/',$title ); } /* Filter to override ...


-1

I sorted this out, $post should be $p in: global $post; $product = new WC_Product( $post->ID );


0

I try to give you some cleanup solution which is basic code setup. For social share: See plugin Social Sharing Toolkit Which is easy sharing and connecting on social networks. Display on posts or use widgets or shortcode. Also Twitter name/hashtag to link converter. use do_shortcode('[social_share]') for display social share anywhere on site. In ...


0

Here's the fix... Change the line in \inc\woocommerce\template-tags-categories.php which reads: $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button ajax_add_to_cart' : '', to: $product->is_purchasable() && $product->is_in_stock() && $product->is_type( 'simple' ) ? 'add_to_cart_button ...


0

By the time woocommerce_checkout_fields filter is run, the arrays for billing and shipping have already been created. You can see that here: https://docs.woothemes.com/wc-apidocs/source-class-WC_Checkout.html#101 If you want to effect the default fields, use this hook. function wpse215677_checkout_fields ( $fields ) { ...


0

Paste this code into your functions.php and it will be solved. add_action('add_to_cart_redirect', 'resolve_dupes_add_to_cart_redirect'); function resolve_dupes_add_to_cart_redirect($url = false) { if(!empty($url)) { return $url; } return get_bloginfo('wpurl').add_query_arg(array(), remove_query_arg('add-to-cart')); }


0

Go to woocommerce folder-> template single product -> product-thumbnail.php from that you need to delete the slider class


0

You are using woocommerce_add_cart_item, Please use woocommerce_before_calculate_totals. add_action( 'woocommerce_before_calculate_totals', 'custom_add_cart_item' ); function custom_add_cart_item( $cart_object ) { foreach ( $cart_object->cart_contents as $key => $value ) { if ( empty( $value['booking'] ) && empty( ...


0

This is solution of your 404 links problem, Got to Settings -> Permalinks -> In 'Product permalink base' select the 'Shop base with category' option. For more you can visit, https://wordpress.org/support/topic/permalinks-404-with-custom-post-type


0

Here is the code for overriding price of product in cart add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' ); function add_custom_price( $cart_object ) { $custom_price = 10; // This will be your custome price foreach ( $cart_object->cart_contents as $key => $value ) { $value['data']->price = $custom_price; ...


0

I solved this by modifying the function linked to in the question to make it recursive. The comments explain my changes: function woocommerce_subcats_from_parentcat_by_ID( $parent_cat_ID ) { $args = array( 'hierarchical' => 1, 'show_option_none' => '', 'hide_empty' => 0, 'parent' => $parent_cat_ID, 'taxonomy' => 'product_cat' ...


0

Here is the answer which I have got // Setting this as a Variable product wp_set_object_terms( $post_id, 'variable', 'product_type' );


0

I believe there are a couple of issues (based on assumption) First off woocommerce_get_template() is now depreciated and replaced by wc_get_template(). You can try updating your code to: <?php if ( is_singular( 'product' ) ) { woocommerce_content(); } else { //For ANY product archive. //Product taxonomy, product search or /shop landing ...


0

You should just need to change the permalink of the page in the back end of WordPress. You may also need to add the short code [woocommerce_my_account] to the page content depending on your version of WooCommerce. This would however also change the account page from my-account to just account aswell.


0

Are other theme overrides working or is this your first modification? I'm unsure as to if the preview takes into account your theme, but I assume the theme is installed and active as this looks like it should work. As for the other question of a hook... Woocommerce emails work based on triggers you call do_action on the specific email hook you want to fire ...


0

Was able to figure it out. The woocommerce SASS wasn't being loaded. Once I moved the woocommerce .scss to the assets folder and ran gulp it started working. Hopefully this helps someone out one day.


0

Apparently a WooCommerce Webhook will automatically disable due to delivery failure. https://docs.woothemes.com/document/webhooks/#section-3 “Disabled” (does not deliver due delivery failures).


2

The code you have provided is incomplete. Not sure if that is the only code you are using to achieve what you want. So, besides first code block which you have provided, bellow I am adding all rest of the code which is required to show the new field on backend in 'Order Details' box and make it editable through custom fields. Please note, in your second code ...


2

Many thanks to Nathan Powell for the fix. Changing get_stylesheet_directory() to get_stylesheet_directory_uri() will return the correct URL. get_stylesheet_directory() returns the absolute server path to child or parent theme (hence my previous issue) whereas get_stylesheet_directory_uri() returns the properly formed URI of child or parent theme. I ...


0

I ended up inserting the payment description. (the one you specify in the woocommerce settings in the Wordpress backend) The "native" build-in woocommerce payment-text is static and doesn't relates to the actual selected payment method. :-( I did this by modifying the woocommerce template file: 1: Copy this template file: ...


0

The way I've done this was to take a copy of content-product.php and paste it into the root of your theme folder. Comment out do_action( 'woocommerce_before_shop_loop_item_title' ); and do_action( 'woocommerce_after_shop_loop_item' ); Quick and dirty, but it worked for me.


0

There was an error in my code. From here: http://www.sitepoint.com/woocommerce-actions-and-filters-manipulate-cart/ Changing // correct quantity unset( $woocommerce->cart->cart_contents[$product_id] ); $woocommerce->cart->add_to_cart( $product_id, $quantity ); To // correct quantity // Get it's unique ID within the Cart $prod_unique_id = ...


0

I was able to use the "export" option (which I didn't know about) to sort of get what I wanted. The product descriptions were the main thing I wanted, the images I already had saved. So I'll see if this works before spending the money.


2

Fixed query select p.ID as order_id, p.post_date, i.order_item_name, max( CASE WHEN im.meta_key = '_product_id' and i.order_item_id = im.order_item_id THEN im.meta_value END ) as Prod_ID from wp_posts as p, wp_postmeta as pm, wp_woocommerce_order_items as i, wp_woocommerce_order_itemmeta ...


1

Unfortunately there is no hook available to remove that "Our Bank Details" text. But, you can hide the default which is added and un-intended area by placing following rule in your theme's style.css file: .woocommerce-order-received .woocommerce h2:nth-of-type(2) { display: none; } Then to have "Our Bank Details" at intended place, simply go to ...


0

I figured it out, it was a pretty simple oversight actually. I forgot the the number after the add or remove action represents priority and by putting the same priority I was messing things up. So i just removed the priority to the remove add to cart action. So my code now looks like this ...


0

Thanks, will do next time. I figured this one out: function my_custom_wc_api_order_response( $order_data, $order, $fields ) { $customer_info = get_post_meta( $order->id, '_customer_info', true ); $order_data['payment_details']['customer_info'] = $customer_info; // Apply filters if necessary if ( $fields ) { $order_data = ...


0

Unless I'm missing something, you're collecting the data through the post, validating it, and storing it, but I'm not seeing how you intended to display the billing_country in the checkout template. Since the billing_country data is stored in the user meta, you could display it in your checkout template using get_user_meta: <?php $billingCountry = ...


0

I have got the solution from avada theme makers: .checkout .shop_table tfoot th { width: 85% !important; }


0

Based on this answer, here is my function to get all your terms in an array : function get_term_ancestors($post_id, $taxonomy){ // Declare the array where we are going to store the terms $ancestors = array(); // start from the current term $parent = array_shift(get_the_terms($post_id,$taxonomy)); // climb up the hierarchy until we reach ...


0

Do you mean the archive title? There is a few ways to do that, but probably the easiest is go the archive-product.php template and edit this line: <h1 class="page-title"><?php woocommerce_page_title(); ?></h1> Add in something like this: <?php if (!is_product_category() && apply_filters( 'woocommerce_show_page_title', true ) ...


0

You need to modify the login form on your custom login page. When using wp_login_form() you can include a redirect URL in the arguments (Codex Entry). The default URL is: ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] But you can override that: if (get_query_var('redirect_to')) { $redirectURL = ...


2

To begin with you may need to add %s to the sprintf function, as the current link has no anchor text and this is supposed to be put in by sprintf as the second argument: return sprintf( '<div class="form-block block-after-indent"><a class="atbtn atbtn--secondary1" href="#sime_url_product_id_%d">%s</a></div>', $product->id, ...



Top 50 recent answers are included