Created
August 23, 2018 20:38
-
-
Save sirwan/4b808b347cec264d0fdd3de659bc32e0 to your computer and use it in GitHub Desktop.
Get children of a grouped product
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is a simple example. | |
/** | |
* Test creating a new grouped product. | |
* | |
* @since 2.7.0 | |
*/ | |
function test_grouped_product_create() | |
{ | |
$simple_product = WC_Helper_Product::create_simple_product(); | |
$product = new WC_Product_Grouped(); | |
$product->set_children(array($simple_product->get_id())); | |
$product->set_name('My Grouped Product'); | |
$product->save(); | |
$read_product = new WC_Product_Grouped($product->get_id()); | |
$this->assertEquals('My Grouped Product', $read_product->get_name()); | |
$this->assertEquals(array($simple_product->get_id()), $read_product->get_children()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment