51419

If product has variation Disable the Quantity in Woocommerce mini cart

Question:

In My theme there If the product has variation Is show some thing like 1x$18=$18 how to remove the Quantity if the product has variations. I need Something Like pack x $18 =$18 but If the Product has no variation it show as it is . Is there any "If condition to apply for variation"? Please help me.

<?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s &times; %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); ?>

I am Trying to make this

<?php if( $product->is_type( 'simple' ) ){ echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s &times; %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); } else{ apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( $product_price ) . '</span>', $cart_item, $cart_item_key ); } $product = new WC_Product( get_the_ID() ); ?>

But not Work

Answer1:

Move this line to top of code instead of end of code.

$product = new WC_Product( get_the_ID() );

Answer2:

Al Last I solve the problem Check this please now this on my theme file <a href="http://www.vapepartsmart.com/" rel="nofollow">Check this here</a>

<?php global $woocommerce, $product, $post; $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); if( $_product->is_type( 'simple' ) ){ echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s &times; %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); }else{ echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( $product_price ) . '</span>', $cart_item, $cart_item_key ); } ?>

Recommend

  • Show caption under product gallery in WooCommerce
  • Can I add content before post content without using the_content filter
  • Woocommerce: Featured image different than product image revision needed
  • Short Description in checkout woocommerce wordpress
  • show div after process register, woocommerce
  • text-align justify, cannot override
  • Angular - routerLinkActive and queryParams handling
  • Is it possible to get the word under the mouse cursor in a ``?
  • Get specific string
  • How does this usort cmp function actually work?
  • Stop Bash Script if Hive Fails
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • Is there a way to do normal logging with EureakLog?
  • Alert pop up with LWUIT
  • Get one-time binding to work for ng-if
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Insert into database using onclick function
  • Fetching methods from BroadcastReceiver to update UI
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • Display Images one by one with next and previous functionality
  • Upload files with Ajax and Jquery
  • Web-crawler for facebook in python
  • Do I've to free mysql result after storing it?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • Cannot Parse HTML Data Using Android / JSOUP
  • Linker errors when using intrinsic function via function pointer
  • A cron job substitute?
  • json Serialization in asp
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Java static initializers and reflection
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • unknown Exception android
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app