Home > OS >  Woocommerce order items not displaying and order subtotal return '0'
Woocommerce order items not displaying and order subtotal return '0'

Time:06-25

Just before when the order is placed in the final checkout page the Subtotal Value displays a respective amount which is correct but just as I checked out the subtotal price returns '0' value and in the order details both in admin end and front-end I'm unable to see the Items purchased which makes it more difficult for customers to see which Product they have purchased.

Now this kind of problem is usually caused by either a conflict with the theme or with another plugin. So I disabled all the plugins except Woocommerce and placed an order, even changed the theme and checked out but the result is the same. No order items are being displayed either in backend or in front-end.

I also checked out the database also where the order item name is being stored in the table "wpry_woocommerce_order_items" but then I find out that no order item data is being inserted in that table that is also one major reason why I'm facing this issue... Is there any solution for this as I'm totally stuck and clueless how to debug next...

Click here to see the issue...

CodePudding user response:

Try this one to inspect the order object (it may give you some insight):

code goes in functions.php or your plugin file:

<?php

// add a debug page in Wp Admin -> Testxd
if ( is_admin() ) {

   add_action( 'admin_menu', 'add_testxd_menu_entry', 100 );
}
function add_testxd_menu_entry() {
   add_menu_page(
     __( 'Test Page', 'textdomain' ),
     'testxd',
     'manage_options',
     'testxd',
     'func_testxd',
     'dashicons-admin-network',
     6
   );
}

// callback function...
function func_testxd () {

echo '<br><br><div style="color: #fff; background: #000;"><br><br>';
function pr($name='', $val=null)
{
  print("<pre> $name" . print_r($val, true) . "</pre>");
}

$order_info = wc_get_order( $order_id );

// inspect the order object...

pr("Order Object:: ", $order_info);
pr("Order Status:: ", $order_info->get_status());


// end testx...
echo '<br><br></div><br><br>';
}

CodePudding user response:

Thanks @json for the code. I've tried out your code but getting one critical error again ...

Click here for screenshot

The issue regarding the order is shown below...

Click here for screenshot

  • Related