Access our premium support and let us know your problems, we will help you solve them.

0
No products in the cart.

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: How to debug in WooCommerce 3+ #9978
    blankyahya-ayyoub
    Participant

    First Creat PHP helper function

     function console_output($data) {
     $output = $data;
    if (is_array($output))
        $output = implode(',', $output);
    
      echo "<script>console.log('Debug Objects: " . $output . "' );</script>";
     }
    

    Then you can use it like this:

    public function calculate_shipping( $package ) {
    // This is where you'll add your rates
    $rate = array(
      'idea' => $this->id,
      'label' => $this->title,
      'cost' => '90.00',
      'calc_tax' => 'per_item'
         );
       console_output("Calculating shipping");
        $this->add_rate($rate);
       }
    

    This will create an output like this:

      Debug Objects: Calculating shipping
    
Viewing 1 post (of 1 total)