PHP code example of level-level / wp-browser-woocommerce
1. Go to this page and download the library: Download level-level/wp-browser-woocommerce library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
level-level / wp-browser-woocommerce example snippets
// ./tests/wpunit/ExampleTest.php
use LevelLevel\WPBrowserWooCommerce\WCTestCase;
class ExampleTest extends WCTestCase{
public function test_something(){
// Create a WooCommerce product.
$product = $this->factory()->product->create_and_get(
array(
'name' => 'test',
'regular_price' => '12.12',
)
);
// Create a WooCommerce order with two products.
$order = $this->factory()->order->create_and_get(
array(
'payment_method' => 'bacs',
'payment_method_title' => 'BACS',
'set_paid' => true,
'line_items' => array(
array(
'product_id' => $product->get_id(),
'quantity' => 2,
),
),
)
);
// Make sure the order total price is correct.
$this->assertEquals( 24.24, $order->get_total() );
}
}