Skip to content

Instantly share code, notes, and snippets.

View tivuno's full-sized avatar
💪
Preparing a bunch of modules for PrestaShop 9

tivuno.com tivuno

💪
Preparing a bunch of modules for PrestaShop 9
  • Milopotamos, Drama, Greece
  • 00:13 (UTC +03:00)
  • X @tivuno_com
View GitHub Profile
<?php
add_action( 'rest_api_init', function () {
function set_custom_sorting( $response ) {
//var_dump([rand()]);
$response->data['custom_order'] = (int) get_term_meta($response->data['id'], 'order', true);
return $response;
}
add_filter( 'woocommerce_rest_prepare_product_attribute_term', 'set_custom_sorting', 10, 1);
<?php
// Link example: https://mywebsite.com/wp-json (because we have woo, acf etc. that deploy their unique endpoints
function getWooCategories(string $link, string $consumer_key, string $consumer_secret)
{
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $link . '/wc/v3/products/categories?per_page=100&consumer_key=' . $consumer_key . '&consumer_secret=' . $consumer_secret,
CURLOPT_RETURNTRANSFER => true,
<?php
$xml = simplexml_load_file('arxeio1.xml');
$filters = $xml->xpath('products/product/filter');
foreach($filters as $filter) {
$feature_name = trim($filter->filter_name);
if ($feature_name == "ΙΣΧΥΣ/WATT") {
// Do something
echo "1<br />";
} elseif ($feature_name == "LUMEN") {