Limiting woocommerce line_total decimal length

Just round the decimal to two digit as per your requirement. $myID = 2859; $myorder = new WC_Order($myID); foreach ($myorder->get_items(‘line_item’) as $item) { $rounded_total = round($item[“line_total”],2);// allow 2 decimal and avoid further $Data = $Data.OrderLine($item[“name”], $rounded_total, $item[“line_tax”], $item[“qty”], “piece”, “x”); }

Display File Types For Woocommerce Downloadable Products On Product Page

Place the following code in your meta.php template file immediately after the lines where it prints the categories and tags. Please note, the standard practice is that you shall copy the meta.php template file to your theme folder. So to override meta.php, copy: woocommerce/templates/single-product/meta.php from plugin folder to yourtheme/woocommerce/templates/single-product/meta.php <?php global $product; $downloads = $product->get_files(); … Read more

Set quantity of woocommerce product on page visit [closed]

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 = $woocommerce->cart->generate_cart_id( $product_id ); // Remove it from the cart by un-setting it unset( $woocommerce->cart->cart_contents[$prod_unique_id] ); $woocommerce->cart->add_to_cart( $product_id, $quantity ); Has … Read more