Jump to content

Pass product combination reference variable to PHP file


grigorevlad

Recommended Posts

Hi,

Unfortunately in PS 1.7.x i can no longer include php in tpl files, in order to do that i created a module and hooked it to displayProductAdditionalInfo.

Every time the user selects a product combination, i need to get the combination reference (specific reference) and call an API to get and display warehouses stocks quantity for that product. 

Everything is working fine except i can't get the combination reference that the user is seeing into the module PHP file where the API process is running. 

This is the part of the file from the module where i need to post the combination reference:

		$data = array(
			'cif'           => $companyVatCode,
			'date'          => date('Y-m-d'),
			'warehouseName' => '',
			'productName'   => '',
			'productCode'   => 'HERE I NEED THE PRODUCT SPECIFIC REFERENCE',	
		);
		try {
			$list = $sbcClient->productsStock($data);
			
			foreach($list as $item){
				foreach($item['products'] as $product){
					$wName = $item['warehouse']['warehouseName'];
					$codprod = $product['productCode'];
					$quantity = $product['quantity'];
					printf("%s%s%s%s%s%s%s".PHP_EOL,'<tr><td>',$wName,'</td><td>',$codprod,'</td><td>',$quantity,'</td></tr>');
				}
			}
		} 

If i manually register a code (ex: 'productCode'   => '5400852326801', ), then on the product page everything loads fine:

sadasd.jpg.efd4b904262363544deff7f1a2171a97.jpg

How can i do this and call the API every time the combination changes? 

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...