Menu
  • HOME
  • TAGS

Customize Quantity Selector in WooCommerce Cart

Tag: woocommerce,cart,shopping

I am using the Canvas theme from WooThemes, and running the WooCommerce plugin for my e-commerce website. My products are measured in Square Feet, and the order quantities range widely with random numbers of sq. ft. ordered.

The units of measure available to me in the WooCommerce cart do not include sq. ft., and the quantity selector only contains pre-selected quantities that range from 1 through 9.

How can I change the unit of measure to show sq. ft. and the quantity amount in the cart / check-out to be input manually as random numbers? For example: 1253 sq. ft.

https://prettyhardwoodflooring.com

Thanks, Gene

Best How To :

In most of WooCommerce, Quantity field is set to Number input type. That's the reason for it.

Below is the screenshot taken from your site.

enter image description here

If you notice in that screenshot, number is set in type. So you need to change it to text in context of your desire result.

<input name="quantity" value="1" title="Qty" class="input-text qty text" type="text">

Replace it with above code and there you GO :)

Tell me if you have any doubt.

Show product's image in “Orders” page - Woocommerce

php,wordpress,woocommerce

Orders are custom post types of shop_order type. Orders do not have thumbnails themselves, but orders have a list of products that were purchased and each product has the possibility of a thumbnail. You can see in the order-details.php template how to get all the items/products associated with any order...

WooCommerce seems to only orderby date and not price

php,ajax,wordpress,woocommerce

Try this: $args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'beast-balls', 'orderby' => 'meta_value_num', 'meta_key' => '_price', 'order' => 'asc' ); ...

How to control HTML output of variable $image in WooCommerce

wordpress,woocommerce,thumbnails

HTML5Blank has a pretty good example that should answer some of your questions, take a look here - spefically line 206 and the actions it's hooked into: add_filter('post_thumbnail_html', 'remove_width_attribute', 10 ); function remove_width_attribute( $html ) { $html = preg_replace( '/(width|height)="\d*"\s/', "", $html ); return $html; } To specifically target the...

WooCommerce query quantity on product page

php,forms,woocommerce

Well I had to add an ajax function to the input field that would then update a hidden field in my form. Then when the Calculate button is pressed, I have access to the updated quantity.

Prestashop Cart Summary : Custom code is disabled when quantities added

cart,prestashop-1.6

You should look at your_theme/js/cart-summary.js file. And I think you should edit updateCartSummary function. Its place where your summary is updating. Other thing: addd new or with different class. It should`nt remove unit price wihout VAT, but also it always stay same price. So you must add line to count...

I Need to add items to array, not replace them

php,arrays,session,save,cart

It seems that you are recreating the array on the second set of code meaning that you will delete everything already in the array. Did you try just array_push without the $_SESSION['cart']=array(); for the second set of code? If not try getting rid of that first line and see if...

Wordpress End If Statements

php,wordpress,woocommerce

<?php if ( sizeof( $woocommerce->cart->cart_contents ) == 0 ) { // The cart is empty } else { ?> <div class="header-cart-inner"> <a class="cart-contents" href="<?php echo WC()->cart->get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->cart_contents_count ), WC()->cart->cart_contents_count ); ?> - <?php echo...

PHP date not taking into account AM/PM properly

php,wordpress,woocommerce

You have to use date_add to add two times properly: $date = date_create($item['Booking Time']); date_add($date, date_interval_create_from_date_string($item['Duration'])); echo date_format($date, 'h:ia'); One line solution: date_format(date_add(date_create($item['Booking Time']), date_interval_create_from_date_string($item['Duration'])), 'h:ia'); ...

Woocommerce API returns 1, but works

php,wordpress,woocommerce

The reason might be that this action is been called via some ajax. In wordpress the ajax default returns the die() function before the function ends. So if we don't specify die() in our custom function it will append 1 with the data in our callback. So you have to...

Woocommerce Return False with message

php,wordpress,woocommerce

You can have a $message variable that is empty for true and contains a messages (in HTML) for false: PHP $message = ""; ... function disable_cart_for_over_fifty_k( $purchasable, $product ){ global $message; if( $product->get_price() >= 50000 ) { $message = "<p class='errorMessage'>This product is over £50,000 - please contact us</p>"; return...

Woocommerce Filter Product by Attribute

filter,attributes,woocommerce,product

You should be able to achieve what you're looking to do by using a tax_query combined with your WP_Query. Attached is a small example using a 'Brand' attribute and the 'EVGA' term inside it (which WooCommerce will turn into 'pa_brand' - product attribute brand). $query = new WP_Query( array( 'tax_query'...

“Validation error: PayPal currencies do not match” in WooCommerce

wordpress,validation,paypal,woocommerce,currency

i found temporary fix for this problem go to “plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php” and comment two lines (line number : 176 and 177 ) like this //$this->validate_currency( $order, $posted['mc_currency'] ); //$this->validate_amount( $order, $posted['mc_gross'] ); Source : https://www.kapadiya.net/wordpress/woocommerce-paypal-for-inr/...

How to add user roles dropdown in registration and login woocommerce wordpress

wordpress,woocommerce,wordpress-plugin-dev,wordpress-loop

Try this : function ts_wp_dropdown_roles( $selected = '' ) { $p = ''; $r = ''; $editable_roles = array_reverse( ts_get_editable_roles() ); foreach ( $editable_roles as $role => $details ) { $name = translate_user_role($details['name'] ); if ( $selected == $role ) // preselect specified role $p = "\n\t<option selected='selected' value='" ....

woocommerce_add_order_item_meta hook sending only one argument; three expected

wordpress,woocommerce,wordpress-plugin-dev

Shame on me!I had not found necessary to add the last two arguments of the add_action() function. So the default number of argument being one, only one was passed to my callback. so the right code for the add_action() function is: add_action('woocommerce_add_order_item_meta', array($this, 'charlie_ajoute_un_order_item_meta'), 10, 3); Hope it may help...

How to read data sent by webhooks?

php,wordpress,woocommerce

$webhookContent = ""; $webhook = fopen('php://input' , 'rb'); while (!feof($webhook)) { $webhookContent .= fread($webhook, 4096); } fclose($webhook); mail('[email protected]', 'test - hook', $webhookContent); This is all it took. It will send all the body to your email...

trouble using AFOAuth2manager to generate HTTPSOauthToken

ios,oauth,woocommerce,afoauth2client

try this NSURL *baseURL = [NSURL URLWithString:urlString]; AFOAuth2Manager *oAuthManager = [[AFOAuth2Manager alloc] initWithBaseURL:baseURL clientID: keyClientID secret:keyClientSecret]; [oAuthManager authenticateUsingOAuthWithURLString:@"/oauth/token" username:myUserName password:myPassword scope:@"email" success:^(AFOAuthCredential *credential) { NSLog(@"Token: %@",credential.accessToken); //Authorizing requests AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:baseURL];...

WooCommerce display product categories in product title

php,wordpress,woocommerce,taxonomy

you can simply get all the categories assign to product by using get_the_terms $terms = get_the_terms( get_the_ID(), 'product_cat' ); foreach ($terms as $term) { echo '<h1 itemprop="name" class="product-title entry-title">'.$term->name.'</h1>'; } ...

Displaying all woocommerce product liks with title in Footer for SEO - Wordpress PHP

php,wordpress,woocommerce,e-commerce

Is this what you wants ? //you can remove post_status=>publish if you want unpublished product also $loop = new WP_Query( array( 'post_type' => 'product','post_status' => 'publish', 'posts_per_page' => '-1' ) ); while ( $loop->have_posts() ) : $loop->the_post(); echo "<a href='".get_post_permalink()."'>".$loop->post->post_title."</a><br>"; endwhile; EDITED change query like this : $loop = new...

Wordpress ordered by two custom fields meta_key's

php,wordpress,woocommerce

Add both meta keys to meta_query and set orderby to meta_value. Then you can replace it with posts_orderby hook. <?php // Override orderby if orderby value = 'meta_value' function orderby_countdown_date_and_hour( $orderby ){ return str_replace( 'meta_value', 'meta_value, mt1.meta_value', $orderby ); } $args = array( 'post_type' => 'product', 'posts_per_page' => 20, 'tax_query'...

Woocommerce product dimensions not showing on first product

php,html,wordpress,web,woocommerce

add_action( 'woocommerce_after_shop_loop_item_title', 'cj_show_dimensions', 9 ); function cj_show_dimensions() { global $product; $dimensions = $product->get_dimensions(); if ( ! empty( $dimensions ) ) { echo '<span class="dimensions">' . $dimensions . '</span>'; } } The above code works well only under the following conditions: If dimensions are added to the product. This code should...

Add custom functionality on WooCommerce complete button

php,ajax,wordpress,wordpress-plugin,woocommerce

this code will fire as soon a customer made a order and arrives on the thankyou page.. add_action( 'woocommerce_order_status_completed', 'custom_task' ); function custom_task( $order_id ) { // Only continue if have $order_id if ( ! $order_id ) { return; } // Get order $order = wc_get_order( $order_id ); // Do...

woocommerce - make order notes required

wordpress,woocommerce

Change the action from 'woocommerce_checkout_process' to 'woocommerce_after_checkout_validation'. add_action('woocommerce_after_checkout_validation', 'my_custom_checkout_field_process'); function my_custom_checkout_field_process() { // Check if set, if its not set add an error. if ( ! $_POST['order_comments'] ) wc_add_notice( __( 'Please enter something into this new shiny field.' ), 'error' ); } ...

Custom Cart icon with count for android

android,drawable,cart

You can simple use one and show a TextView over it containing the number of items Use can use this as a background for your TextView <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="5dp"/> <stroke android:color="#3CA9C1" android:width="3dp"/> <solid android:color="#FFFFFF"/> </shape> You can simply draw the text over the image like...

Woocommerce simple filter php

php,wordpress,woocommerce

Currently you are cheching if status IS NOT failed and then redirect. Change if ( $order->status != 'failed' ) { to if ( $order->get_status() == 'failed' ) { See PHP comparison operators. Also, you are not getting correct order. Your function should take $order_id and load correct order. add_action( 'woocommerce_thankyou',...

WooCommerce - Display categories and its products on front page

php,wordpress,woocommerce

First you'll need to query the products from a category: $args = array( 'posts_per_page' => -1, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => 'category-slug1' //Your category goes here ), ), 'post_type' => 'product', 'orderby' => 'title', ); $first_cat_query = new WP_Query( $args...

How To check Product Have Variation in woocommerce

php,wordpress,woocommerce,product

This should work: if( $product->is_type( 'simple' ) ){ // No variations to product } elseif( $product->is_type( 'variable' ) ){ // Product has variations } Example: If you will replace the file woocommerce --> single-product --> meta.php with this code, you will see it works. <?php /** * Single Product Meta...

WooCommerce - Checking for brand page

php,wordpress,wordpress-plugin,woocommerce

I managed to find a solution to this problem using the is_tax() function that Wordpress provides for using on custom taxonomy archives. Here's my code to check if I'm on a brand page or not. Have tested and appears to be working fine. function is_brand_page_check() { if (is_tax( 'product_brand' ))...

Wordpress - customized pages with blocks - prohibit google seo index of blocks

wordpress,seo,woocommerce,robots.txt,google-sitemap

Noindex tags would be useful. https://support.google.com/webmasters/answer/93710?hl=en

Add second single product page in Woocommerce

wordpress,woocommerce

What I would do in this case is add a link that will reload the page with a custom query arg in the URL. Then you can filter the template via template_include to load a different template. Untested, so be careful of syntax typos. add_filter( 'template_include', 'so_30978278_single_product_alt' ); function so_30978278_single_product_alt(...

Woocommece login URL

wordpress,woocommerce

Try this code: function redirect_login_page(){ if(is_user_logged_in()){ return; } global $post; // Store for checking if this page equals wp-login.php // permalink to the custom login page $login_page = get_permalink( 'CUSTOM_LOGIN_PAGE_ID' ); if( has_shortcode($post->post_content, "woocommerce_my_account") ) { wp_redirect( $login_page ); exit(); } } add_action( 'template_redirect','redirect_login_page' ); ...

WooCommerce: How to display Category Name in single-product.php

php,wordpress,woocommerce

Try this : global $post; $terms = get_the_terms( $post->ID, 'product_cat' ); foreach ($terms as $term) { echo $term->name .' '; $thumbnail_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); echo "'{$image}'"; } ...

Wordpress woocommerce - hide flat rate when free shipping

wordpress,woocommerce,shopping-cart

You're using the old method, you need to use this new one I think. Copied from WooThemes website: add_filter( 'woocommerce_package_rates','hide_shipping_when_free_is_available', 10, 2 ); function hide_shipping_when_free_is_available( $rates, $package ) { // Only modify rates if free_shipping is present if ( isset( $rates['free_shipping'] ) ) { // To unset a single rate/method,...

Woocommerce hide payment gateway for user roles

php,wordpress,woocommerce

Have mention the code which is tried and tested for you. It works well. Lemme know if the same works for you too. function wdm_disable_cod( $available_gateways ) { //check whether the avaiable payment gateways have Cash on delivery and user is not logged in or he is a user with...

fabricjs: how to show object size after scaling

javascript,jquery,wordpress,woocommerce,fabricjs

I don't think it is a good idea to change the fabricJs source. It would be better to extend it or make some functions. I made you jsFiddle with how to get the width and height of the object while it is scaling. canvas.on('object:scaling', function(){ var obj = canvas.getActiveObject(); $('#rect-width').val(Math.floor(obj.getWidth()));...

How to display grouped products in a list with quantity in woocommerce?

wordpress,woocommerce

You can read about WooCommerce's template overrides. If you aren't seeing the default with your theme that means that your theme is overriding it. I can't be sure, but probably you need to go into your theme's woocommerce folder.... and find the grouped.php template in: yourtheme/woocommerce/single-product/add-to-cart/grouped.php and rename it to...

WooCommerce REST API v2: How to process payment?

rest,woocommerce,payment-gateway

As helgatheviking concurred, there currently isn't a way to process payment of an order with the WooCommerce REST API. I ended up writing a hook into the the woocommerce_api_create_order filter that immediately processes the order for payment when the order is created. If the processing fails, then the errors are...

change the subtotal dynamically when the quantity changes in shopping cart

javascript,jquery,shopping-cart,cart

$(document).ready(function(){ $("#quantity").change(function(){ $("#subTotal").val(parseInt($(this).val()) * parseInt($("#price").val())); }); }); I have added a plunker for you - http://plnkr.co/edit/aF6G1SSJZTLREH6cBBul Firstly, add your code in document ready block as it executes your code only after the document is ready. Secondly, bind the onchange event with input field with id quantity and do all the...

Retrieve data from cart and send using mail

php,codeigniter,cart

use jquery and capture the html table that you want to send as email. and pass the variable to the email function using ajax, try this, <script> $(document).ready(function() { var htmlstring = $("#mail_table").html(); $( "#send" ).click(function() { var cn_name = $("#cn_name").val(); var cn_mail = $("#cn_mail").val(); $.ajax({ method : 'post', dataType...

How to set woocommerce checkout form values to empty

wordpress,wordpress-plugin,woocommerce

Not sure with your exact issue , but there might be two possible situations in your case. You might me logged in with same user and then trying to checkout, as woo-commerce will fetch the details of currently active user and auto fill it during checkout. Fields might get auto...

Select woocommerce chosen shipping method price

php,wordpress,woocommerce

Did you try this inside your foreach loop? $rate = $package['rates'][$chosen_method]->cost; ...

Remove item with $product_id - Woocommerce

php,wordpress,woocommerce

I think You are using remove_cart_item wrongly. If you go through the documentation, you will find that it accepts cart_item_key as parameter(as wisdmLabs mentioned in comment). And you are using it like WC()->cart->remove_cart_item($product_3); instead of wc()->cart->remove_cart_item($cart_item_key); So by replacing that line, I think you will able to remove product....

WordPress - Failing to override woocommerce templates

wordpress,templates,woocommerce,override

While the directory structure in the WooCommerce plugin itself is: /plugins/woocommerce/templates/ You should define it like the following in your theme (note the missing templates dir): /yourtheme/woocommerce/ In other words, you should put all of the overrides directly within the woocommerce/ directory (there will be no templates/ directory). This is...

How get variation's stock quantity woocommerce

php,woocommerce,stock,variations,variation

Ok, with this I can take the quantity. But is not useful. With this I can prepare a code that make differents sentences, one for each product, and show it when a variation would be selected using jquery. But this is not good idea. Is not elegant. I though existed...

How can I set the Image of woocommerce category as the background of the category title? [duplicate]

php,html,wordpress,woocommerce

<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?> <h1 style="background: url(<?php if ( is_product_category() ){ global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); echo "'{$image}'"; } ?>);" class="page-title"><?php woocommerce_page_title(); ?></h1> I followed How to display Woocommerce Category image? and...

WooCommerce orders page add customer role custom column

php,wordpress,woocommerce

Add below code in your theme functions.php add_filter('manage_edit-shop_order_columns', 'add_column_heading', 20, 1); function add_column_heading($array) { $res = array_slice($array, 0, 2, true) + array("customer_role" => "Customer Role") + array_slice($array, 2, count($array) - 1, true); return $res; } add_action('manage_posts_custom_column', 'add_column_data', 20, 2); function add_column_data($column_key, $order_id) { // exit early if this is not...

how to set different minimum order amount for free shipping for different user roles in woocommerce

php,wordpress,woocommerce

Have you considered using a plugin for this? I've created a plugin that can be configured with conditions, including based on user role. https://wordpress.org/plugins/woocommerce-advanced-free-shipping/...

woocommerce conditional products/categories on user role

wordpress,wordpress-plugin,woocommerce

To achieve this you can use the Free Groups plugin. But for that you must add all the wholesalers to one group say wholesale group 1. Then while editing any product you get an option to access to, add the wholesaler group 1 there. The product will now be only...

Upgrade to Woocommerce 2.3.10 caused checkout to block

php,wordpress,woocommerce

I finally found the answer to the problem. I had inserted "echo" statements in the functions.php for my theme and this was causing a hidden error condition that I could not see. I removed the "echo" statements and things started working again.

How to remove the quantity field from cart page for specific product attribute WooCommerce

php,wordpress,woocommerce

$attributes = $product->get_attributes(); only returns an array of the product's attributes, so you would at least need some kind of conditional logic as returning the attributes alone would not be enough. If you notice this line: echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key ); You don't need to override the cart.php template...

WooCommerce - Change the shop page layout but keep the archive-product.php

php,wordpress,woocommerce

Take a look at the taxonomy-product_cat.php and taxonomy-product_tag.php templates and you will see that they both call the archive-product.php template. wc_get_template( 'archive-product.php' ); Therefore, if you wish to change the shop archive, but not the taxonomy archives you need to duplicate the archive-product.php to another file... say: archive-product-alt.php and change...