Skip to content

Instantly share code, notes, and snippets.

View amirhmoradi's full-sized avatar
🛥️
Working from boat

Amir Moradi amirhmoradi

🛥️
Working from boat
View GitHub Profile
@amirhmoradi
amirhmoradi / gist:1d54cdc19ca7ddea0b8685a1ffa03941
Created February 25, 2024 21:37
Move Woocommerce product bundles display block
/**
* move woo bundled products on product page form from "woocommerce_before_add_to_cart_button" to "woocommerce_after_single_product_summary"
*/
function ax_wc_product_bundles_move_singleproduct_display() {
if ( class_exists('WC_PB_BS_Display') ) {
remove_action( 'woocommerce_before_add_to_cart_button', array( 'WC_PB_BS_Display', 'display_bundle_sells' ), 1000 );
global $product;
if ( $product->is_type( 'variable' ) ) {
Country Code State Code ZIP/Postcode City Rate % Tax Name Priority Compound Shipping Tax Class
AT * * * 20 USt 1 0 1
BE * * * 21 TVA 1 0 1
BG * * * 20 ДДС 1 0 1
CY * * * 19 ΦΠΑ 1 0 1
CZ * * * 21 DPH 1 0 1
DE * * * 19 MwSt 1 0 1
DK * * * 25 moms 1 0 1
EE * * * 20 km 1 0 1
EL * * * 24 ΦΠΑ 1 0 1
@amirhmoradi
amirhmoradi / How to send bulk-mass email.md
Created November 2, 2023 22:46 — forked from MaximilianKohler/How to send bulk-mass email.md
How to send bulk/mass email with Amazon SES. 10,000-100,000 one-time emails, or thousands per day. Set up your own web server for newsletters. Mailchimp alternative

How to send bulk/mass email

The short answer is that you need to set up your own web server (Hetzner, AWS, DigitalOcean, etc.), install an email software on it (Listmonk, Mailwizz, Mautic), and use an SMTP like Amazon SES. It's not that hard. If you're on Windows, Putty and FileZilla will be your main programs to access your server. When using CSV files for your contacts, you want to use UTF-8 format.

There are some detailed guides below for Sendy and Listmonk. But even if you have/want to hire someone to set it up for you, they should be able to do so for under $60 (check Fiverr). So it's still the most affordable option.

When I searched for this I had a very hard time finding a right answer because all the results were SEO blogs advertising their newsletter services (Mailchimp, Convertkit, etc.), which is not the same thing.

My use case is that I have a Google form collecting tens of thousands of applications. And I need to re

@amirhmoradi
amirhmoradi / woocommerce-brands_add_brand_to_woocommerce-google-analytics-pro.php
Created August 28, 2023 13:49
Woocommerce Brands Add Product Brand to Woocommerce Google Analytics Pro data
<?php
// Add product brand to Woocommerce google analytics pro plugin
function ax_wc_gapro_add_product_brand($aProduct=[]){
if(empty($aProduct['brand'])){
$iProductId = wc_get_product_id_by_sku($aProduct['id']);
$aProduct['brand'] = implode(', ', wp_get_post_terms($iProductId, 'product_brand', ['fields' => 'names']));
}
return $aProduct;
}
@amirhmoradi
amirhmoradi / woocommerce-brands_add_brand_to_stapeio_server-side_gtm.php
Created August 28, 2023 13:42
Woocommerce Brands Add Brand to Stape.io Server-Side GTM
<?php
// Add product brand to stape sst gtm:
function ax_set_product_brand_taxonomy(){
return 'product_brand';
}
add_filter( 'gtm_server_side_product_brand_taxonomy', 'ax_set_product_brand_taxonomy', 1 );
@amirhmoradi
amirhmoradi / woocommerce-pre-orders-plugin-allow-multiple-products-in-cart.php
Last active August 28, 2023 13:48
Woocommerce pre-orders plugin allow multiple products in cart
<?php
//remove pre-order limitations --> only one item per order
function ax_remove_validation_cart(){
if (!empty($GLOBALS['wc_pre_orders'])){
remove_filter( 'woocommerce_add_to_cart_validation', array( $GLOBALS['wc_pre_orders']->cart, 'validate_cart' ), 15, 2 );
}
}
add_action( 'init', 'ax_remove_validation_cart' );
@amirhmoradi
amirhmoradi / mta-sts.js
Created August 28, 2023 07:41 — forked from Tugzrida/mta-sts.js
MTA-STS Cloudflare worker
// This worker is designed to be able to neatly handle MTA-STS policies for multiple domains.
// Make a new worker with this script and add your domains to the stsPolicies dict like the example.
// Add a DNS AAAA record for mta-sts.yourdomain.com pointing to 100:: and set to proxied,
// then add a workers route for mta-sts.yourdomain.com/* pointing to this worker.
// You'll still need to manually add the appropriate _mta-sts.yourdomain.com TXT record to enable the policy,
// and the _smtp._tls.yourdomain.com TXT record for reporting.
const stsPolicies = {
@amirhmoradi
amirhmoradi / openai_translator.py
Created April 18, 2023 12:23
Use OpenAI API to translate json dictionaries
# Description: This script uses OpenAI's API to translate the English text in the JSON file to Persian language.
# You can change the context and languages by changing the task description and the model engine in the variables:
# - task_description
# - model_engine
#
# Make sure to set file paths for the source and destination files in the variables:
# - source_file
# - destination_file
#
# The script will generate temporary files for each batch of translated text, and then combine them into a single file.
/**
* This allows you to select custom pages types (in this example, post_type of 'legal') as your Wordpress's "Privacy Policy page"
* from Wordpress Admin > Settings > Privacy
**/
function amirhmoradi_add_legal_pages_to_get_pages($pages, $parsed_args)
{
$legal_pages = get_posts(array(
'post_type' => 'legal'
));
return array_merge($pages,$legal_pages);
@amirhmoradi
amirhmoradi / wordpress_themes_mysaas_child_theme_functions.php
Created April 26, 2022 14:51
Wordpress Woocommerce Force custom page/post ID as Terms and Conditions page
/**
* This allows you to use a custom page (custom post type) as your WooCommerce "Terms and Conditions" page.
* Once set, you wont need to select the page in Woocommerce settings.
**/
function amirhmoradi_force_terms_page_to_wc($page_id)
{
return 207;
}
add_filter('woocommerce_get_terms_page_id', 'amirhmoradi_force_terms_page_to_wc', 10, 2);