XmlImportWooCommerceData.php 985 Bytes
Newer Older
Nahla Shiri's avatar
Nahla Shiri committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
<?php

require_once dirname(__FILE__) . '/XmlImportWooCommerceProduct.php';
require_once dirname(__FILE__) . '/XmlImportWooCommerceShopOrder.php';

/**
 * Is used to parse XML using specified template and root node
 */
class XmlImportWooCommerceData {	

	public $importer = false;

	public function __construct( $request )
	{		
		switch ($request['import']->options['custom_type']) 
		{
			case 'product':			
				$this->importer = new XmlImportWooCommerceProduct( $request );
				break;			

			case 'shop_order':				
				$this->importer = new XmlImportWooCommerceShopOrder( $request );							
				break;

			default:
				# code...
				break;
		}
	}

	public function parse()
	{
		return ($this->importer) ? $this->importer->parse() : false;
	}

	public function import( $data )
	{
		return ($this->importer) ? $this->importer->import( $data ) : false;
	}

	public function after_save_post( $data )
	{
		return ($this->importer) ? $this->importer->after_save_post( $data ) : false;
	}
}