Files
Jacek Pyziak 4d2561ce4e Add PrivateShop module templates and initial setup files
- Created restricted.tpl for displaying restricted access messages with customizable background options.
- Added index.php files in hook and main template directories to prevent direct access and ensure proper redirection.
- Implemented info.tpl to provide module information and support links, enhancing user experience with promotional content.
- Included necessary CSS styles for the new templates to ensure proper layout and responsiveness.
2025-07-04 01:27:12 +02:00

97 lines
3.5 KiB
PHP

<?php
/**
* Plik umożliwiający zdefiniowanie własnego kodu do przetwarzania danych wymienianych przez API FirmesLink
* dostępne uchwyty: afterProductAdd, afterProductUpdate
* API inicjuje silnik presty, mozna normalnie korzystac z jej obiektow
*
*/
if (!defined('_FL_GET_ADDRESS_FROM_CUSTOM_FIELD'))
define('_FL_GET_ADDRESSES_FROM_CUSTOM_FIELD', 0);
if (!defined('_FL_SET_ORIGINAL_ADDRESS_AS_DELIVERY_ADDRESS'))
define('_FL_SET_ORIGINAL_ADDRESS_AS_DELIVERY_ADDRESS', 0);
if (!defined('_FL_ADD_INVOICE_INFO_TO_ORDER_NOTE'))
define('_FL_ADD_INVOICE_INFO_TO_ORDER_NOTE', 0);
class FirmesLinkCustomActions {
public static function beforeOrderSend($orderId, $orderData = array()) {
if(_FL_GET_ADDRESS_FROM_CUSTOM_FIELD)
{
$q = "SELECT * FROM "._FL_DB_PREFIX."custom_field_userdata WHERE id_order = ".$orderId. " AND id_cart = (SELECT id_cart FROM "._FL_DB_PREFIX."orders where id_order = ".$orderId.")";
LogWrite("Custom SQL: ".$q);
$result = db_query($q);
if($result)
{
if($result->num_rows>0)
{
if(!isset($orderData['orderAddresses'][1]['address']) && _FL_SET_ORIGINAL_ADDRESS_AS_DELIVERY_ADDRESS)
{
$orderData['orderAddresses'][1]['address'] = $orderData['orderAddresses'][0]['address'];
$orderData['orderAddresses'][1]['address']['type'] = 2;
// $orderData['orderAddresses'][1]['address']['orderAddressId'] = 1;
// $orderData['orderAddresses'][1]['address']['customerAddressId'] = 1;
}
while($row = db_fetch_array($result))
{
switch ($row['id_custom_field'])
{
case '1':
// Chcę otrzymać fakturę
if(_FL_ADD_INVOICE_INFO_TO_ORDER_NOTE)
{
$orderData['note'] .= " Faktura: ".$row['field_value']."\r\n";
}
break;
case '2':
// Firma
$orderData['orderAddresses'][0]['address']['name'] = $row['field_value'];
$orderData['orderAddresses'][0]['address']['fullName'] = $row['field_value'];
break;
case '3':
// NIP
$orderData['orderAddresses'][0]['address']['taxNumber'] = $row['field_value'];
if(strlen($row['field_value'])>4)
{
$orderData['orderAddresses'][0]['address']['customerType'] = 2;
}
break;
case '4':
// Adres (Ulica)
$orderData['orderAddresses'][0]['address']['street'] = $row['field_value'];
break;
case '5':
// Miasto
$orderData['orderAddresses'][0]['address']['city'] = $row['field_value'];
break;
case '6':
// Kod pocztowy
$orderData['orderAddresses'][0]['address']['postCode'] = $row['field_value'];
break;
default:
# code...
break;
}
}
}
}
else
{
LogWrite("Custom SQL: Blad wykonania zapuytania SQL");
}
}
return $orderData;
}
}