Skip to content

Instantly share code, notes, and snippets.

View ravahdati's full-sized avatar

Rasool Vahdati ravahdati

View GitHub Profile
@ravahdati
ravahdati / woocommerce-remove-specific-categories-from-related-products.php
Created March 23, 2024 15:44
Remove Specific Categories From Related Products In Woocommerce
@ravahdati
ravahdati / woocommerce-calculate-total-sales-by-product-category.php
Created February 28, 2024 09:49
WooCommerce - Calculate Total Sales By Product Category
/**
* @snippet Calculate Total Sales By Product Category
* @author Rasool Vahdati
* @compatible WooCommerce 7
*/
/**
* Retrieve orders containing products from a specific category - Written by Rodolfo Melogli
*
* @param string $cat_slug The slug of the product category.
@ravahdati
ravahdati / php-soap.php
Last active February 28, 2024 09:23 — forked from akalongman/php-soap.php
PHP soap client example
// Setting SOAP configuration to disable WSDL caching and adjust socket timeout
ini_set('soap.wsdl_cache_enabled', 0); // Disable WSDL caching
ini_set('soap.wsdl_cache_ttl', 900); // Set the time to live for cached WSDL files to 900 seconds (15 minutes)
ini_set('default_socket_timeout', 15); // Set the default socket timeout to 15 seconds
// Define parameters for the SOAP request
$params = array('param1'=>$param1);
// Define the WSDL URL
$wsdl = 'http://service_url/method?WSDL';
@ravahdati
ravahdati / woocommerce-calculate-orders-count-by-product-category.php
Last active February 8, 2024 13:57
WooCommerce - Calculate Orders Count By Product Category
/**
* @snippet Calculate Orders Count By Product Category
* @author Rasool Vahdati
* @compatible WooCommerce 7
*/
/**
* Retrieve orders containing products from a specific category - Written by Rodolfo Melogli
*
* @param string $cat_slug The slug of the product category.
@ravahdati
ravahdati / convert-wp-image-to-base64.php
Last active January 20, 2021 14:09
Convert WordPress image to base64 by attach_id
<?php
function tidaweb_image_url_to_base64( $attach_id )
{
// get image src -> $image_info[0]
$image_info = wp_get_attachment_image_src( $attach_id, 'full' );
$image_file = file_get_contents( $image_info[0] );
// get filename from url
$filename = basename( get_attached_file( $attach_id ) );
$image_file_type = wp_check_filetype( $filename );
@ravahdati
ravahdati / upload-base64-image-to-wp.php
Last active November 13, 2020 20:54
Upload base64 images to wordpress upload directory
<?php
function tidaweb_upload_base64_image( $base64_image_data, $base64_file_name )
{
// check and get path of upload directory
$upload_dir = wp_upload_dir();
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR;
$img = $base64_image_data;
if(strpos($img, 'image/jpg') !== false)
{