fbpx
Simple Smartlink Generation Tool for Kitchens Bespoke

'B', 'NAME' => 'C', 'DATE' => 'D', 'FEEDBACKDATE' => 'E', 'DESCRIPTION' => 'F', 'LINK' => 'G', 'PRODUCTREF' => 'H', 'ORDERREF' => 'I', 'AMOUNT' => 'J', 'CURRENCY' => 'K', 'CATEGORY' => 'L', 'CUSTOMERREF' => 'M', 'MERCHANTIDENTIFIER' => 'N', 'TAGS' => 'O' ); // this "if" checks that all required fields exist and are not empty $smartlink=""; if ( !empty($merchantidentifier) && !empty($email) && !empty($name) && !empty($descriptions) && !empty($productrefs) && !empty($orderref) ) { // this enormous "if" checks whether the multiline fields all have the same number of items if ( (count($descriptionsarray) == count($productrefsarray)) && (empty($productlinksarray) or (count($productlinksarray) == count($descriptionsarray))) && (empty($categoriesarray) or (count($categoriesarray) == count($descriptionsarray))) && (empty($amountsarray) or (count($amountsarray) == count($amountsarray))) ) { $initialparams = ""; $initialparams .= $MARKERSTART . $MARKERS['MERCHANTIDENTIFIER'] . $merchantidentifier; $initialparams .= $MARKERSTART . $MARKERS['EMAIL'] . $email; $initialparams .= $MARKERSTART . $MARKERS['NAME'] . $name; $initialparams .= $MARKERSTART . $MARKERS['ORDERREF'] . $orderref; if ( isset($date) and trim($date)!='' ) { $initialparams .= $MARKERSTART . $MARKERS['DATE'] . $date; } if ( isset($customerref) and trim($customerref)!='' ) { $initialparams .= $MARKERSTART . $MARKERS['CUSTOMERREF'] . $customerref; } if ( isset($feedbackdate) and trim($feedbackdate)!='' ) { $initialparams .= $MARKERSTART . $MARKERS['FEEDBACKDATE'] . $feedbackdate; } if ( isset($currencyid) and trim($currencyid)!='' ) { $initialparams .= $MARKERSTART . $MARKERS['CURRENCY'] . $currencyid; } $count = 1; foreach ($descriptionsarray as $description) { $initialparams .= $MARKERSTART . $MARKERS['DESCRIPTION'] . $count . $description; $count++; } $count = 1; foreach ($productrefsarray as $productref) { $initialparams .= $MARKERSTART . $MARKERS['PRODUCTREF'] . $count . $productref; $count++; } if ( isset($productlinksarray) ) { $count = 1; foreach ($productlinksarray as $productlink) { $initialparams .= $MARKERSTART . $MARKERS['LINK'] . $count . $productlink; $count++; } } if ( isset($amountsarray) ) { $count = 1; foreach ($amountsarray as $amount) { $initialparams .= $MARKERSTART . $MARKERS['AMOUNT'] . $count . $amount; $count++; } } if ( isset($tags) ) { $count = 1; foreach ($tags as $tag) { $initialparams .= $MARKERSTART . $MARKERS['TAG'] . $count . $tag; $count++; } } $key = sha1(sha1($initialparams . $sharedkey) . $sharedkey); $smartlink = bin2hex($initialparams) . $key; // the following commented out echo statements can be used for troubleshooting unexpected output // they show each process of generating the SmartLink /* echo("Parameter string: " . $initialparams . PHP_EOL); echo("sha1 of " . $initialparams . $sharedkey . " = " . sha1($initialparams . $sharedkey) . PHP_EOL); echo("sha1 of " . sha1($initialparams . $sharedkey) . $sharedkey . " = " . $key . PHP_EOL); */ // this last echo prints out the generated SmartLink. To use it programmatically, just use the $smartlink variable //echo("SmartLink: " . $smartlink . PHP_EOL); } else { echo("Multiline arguments must have the same number of elements!" . PHP_EOL); } } else { echo("Required arguments are missing!" . PHP_EOL); } ?>
ParameterValueInfo
Email* Email address of the recipient, e.g. someone@example.com
Name* The name of the recipient, e.g. Mr Customer or Dave Customer
Select product* The description and associated sku of what is to be reviewed. This is what may be displayed publically on Feefo.
Order Ref* A unique value for this transaction.
Date Transaction date in dd/mm/yyyy format
Customer Ref Optional reference. E.g. staff number or code.
" . $initialparams . "
" . PHP_EOL); echo("Smartlink:
" . $url1 . $smartlink . PHP_EOL); } ?>