<commit_before><?php
/**
 * Google Tag Manager Enhanced Ecommerce
 * Ecommerce functionality, tracking, data layer pushing
 *
 * @package silverstripe-blacklist
 * @license MIT License https://github.com/Cyber-Duck/Silverstripe-Google-Tag-Manager/blob/master/LICENSE
 * @author  <<EMAIL>>
 **/
class EnhancedEcommerce {

	/**
	 * Create an ecommerce transaction consisteing of the trnsaction fields and order items
	 *
	 * @param array $order A multidimensional array containing our purchased items
	 * 
	 * @return string
	 */
	public function purchase($order)
	{
		if(!empty($purchases)) :
			$purchase  = "'ecommerce' : {";
			$purchase .= "'purchase' : {";

			$i = 1;
			// Set the transaction order fields
			$purchase .= "'actionField' : {";
			foreach($order['fields'] as $key => $value) :
				$total = count($order['fields']);

				$purchase .= "'".$key."' : '".$value."'";
				$purchase .= $i < $total ? ',' : '';

				$i++;
			endforeach;
			$purchase .= '},';

			$purchase .= "'products' : [";
			$i = 1;
			// lopp through our products
			foreach($order['items'] as $item) :
				$purchase .= "{";

				$e = 1;
				// loop through the indivdual product attributes
				foreach($item as $key => $value) :
					$purchase .= "'".$key."' : '".$value."'";
					$purchase .= $e < count($item) ? ',' : '';
					$e++;
				endforeach;
				$purchase .= "}";
				$purchase .= $i < count($order['items']) ? ',' : '';

				$i++;
			endforeach;
			$purchase .= ']';

			$purchase .= "}";
			$purchase .= "}";

			return $purchase;
		endif;
	}

	public function productImpression()
	{

	}

	public function productClick()
	{
		
	}

	public function productDetail()
	{
		
	}

	public function cartAdd()
	{
		
	}

	public function cartRemove()
	{
		
	}

	public function promotionImpression()
	{
		
	}

	public function promotionClick()
	{
		
	}

	public function checkoutStep($number = 1)
	{
		
	}

	public function checkoutOption()
	{
		
	}

	public function checkoutOption()
	{
		
	}
}<commit_msg>add commerce to develop<commit_after><?php
/**
 * Google Tag Manager Enhanced Ecommerce
 * Ecommerce functionality, tracking, data layer pushing
 *
 * @package silverstripe-blacklist
 * @license MIT License https://github.com/Cyber-Duck/Silverstripe-Google-Tag-Manager/blob/master/LICENSE
 * @author  <<EMAIL>>
 **/
class EnhancedEcommerce {

	/**
	 * @var boolean $false Set whether the ecommerce data layer should show
	 */
	public $show = false;

	/**
	 * Create an ecommerce transaction consisting of the transaction fields and order items
	 *
	 * @param array $order A multidimensional array containing our purchase fields and items
	 * 
	 * @return string
	 */
	public function purchase($order)
	{
		if(!empty($order)) :
			$data = "'purchase' : {";

			$i = 1;
			// Set the transaction order fields
			$data .= "'actionField' : {";
			foreach($order['fields'] as $key => $value) :
				$total = count($order['fields']);

				$data .= "'".$key."' : '".$value."'";
				$data .= $i < $total ? ',' : '';

				$i++;
			endforeach;
			$data .= '},';

			$data .= "'products' : [";
			$i = 1;
			// lopp through our products
			foreach($order['items'] as $item) :
				$data .= "{";

				$e = 1;
				// loop through the indivdual product attributes
				foreach($item as $key => $value) :
					$data .= "'".$key."' : '".$value."'";
					$data .= $e < count($item) ? ',' : '';
					$e++;
				endforeach;
				$data .= "}";
				$data .= $i < count($order['items']) ? ',' : '';

				$i++;
			endforeach;
			$data .= ']';

			$data .= "}";

			$this->show = true;

			return $data;
		endif;
	}

	/**
	 * Create an ecommerce refund consisting of the transactions to refund
	 *
	 * @param array $ids An array of transaction ids to refund
	 * 
	 * @return string
	 */
	public function refund($ids)
	{
		if(!empty($ids)) :
			$transactions = array();

			$data = "
			'refund' : {
				'actionField' : [";

			foreach($ids as $id) :
				$transactions[] = "{'id' : '".$id."'}";
			endforeach;

			$data .= implode(',',$transactions);
			$data .= "
				]
			}";

			$this->show = true;

			return $data;
		endif;
	}

	public function productImpression()
	{

	}

	public function productClick()
	{
		
	}

	public function productDetail()
	{
		
	}

	public function cartAdd()
	{
		
	}

	public function cartRemove()
	{
		
	}

	public function promotionImpression()
	{
		
	}

	public function promotionClick()
	{
		
	}

	public function checkoutStep($number = 1)
	{
		
	}

	public function checkoutOption()
	{
		
	}

	public function partialRefund()
	{
		
	}
}
{'fraction_non_alphanumeric': 0.1771705597179374, 'fraction_numerical': 0.0017628911414720142, 'mean_word_length': 2.763681592039801, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5378310', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1487, 'n_words': 370}