Skip to content

Instantly share code, notes, and snippets.

View elias1435's full-sized avatar
๐Ÿ•‹
Working from home

Md. Elias elias1435

๐Ÿ•‹
Working from home
View GitHub Profile
@elias1435
elias1435 / functions.php
Created August 17, 2023 15:47
How to display acf product field in woocommerce order email. ACF field name is 'customer_email' and its location is product. blow code will go to functions.php
add_action( 'woocommerce_order_item_meta_end', 'custom_product_info', 20, 4 );
function custom_product_info ( $item_id, $item, $order, $plain_text ) {
$id = $item->get_product_id();
$product_info = get_field('customer_email',$id);
if($product_info){
echo "<p>Customer Message: $product_info</p>";
}}
@elias1435
elias1435 / functions.php
Created August 21, 2023 16:50
WooCommerce Mini Cart is coming Blank on add to cart from product page. code will do under functions.php make sure you are using child theme.
function enqueue_wc_cart_fragments() {
wp_enqueue_script( 'wc-cart-fragments' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_wc_cart_fragments' );
@elias1435
elias1435 / package.json
Created December 11, 2023 15:59 — forked from hasinhayder/package.json
Shopify App Extension with Local Script
{
"name": "faq-laravel",
"private": true,
"license": "UNLICENSED",
"scripts": {
"shopify": "shopify",
"build": "shopify app build",
"dev": "shopify app dev",
"info": "shopify app info",
"scaffold": "shopify app generate extension",
@elias1435
elias1435 / qr_code.liquid
Created December 14, 2023 17:26 — forked from hasinhayder/qr_code.liquid
QR Code Block
{% assign full_url = request.host | append: request.path %}
<div style="position: fixed; bottom: 0; right: 0">
{% comment %} {{ "thumbs-up.png" | asset_url | img_tag }} {% endcomment %}
<img width="150" height="150" src="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl={{ full_url }}" alt=""/>
</div>
{% schema %}
{
"name": "App Embed",
"target": "body",
"settings": []
@elias1435
elias1435 / script.js
Created December 26, 2023 06:46
Remove characters with JS and wrap with the html element
// Get all elements with the selector '.variation-Option div'
const elements = document.querySelectorAll('.variation-Option div');
// Iterate through each element and remove "(", "+", and ")" excluding content inside <span>
elements.forEach(element => {
// Iterate through child nodes of the element
for (let i = 0; i < element.childNodes.length; i++) {
const node = element.childNodes[i];
// Check if the node is a text node and not inside a <span>
@elias1435
elias1435 / script.js
Created January 19, 2024 08:16
Match String and add selector by native js
<script>
document.addEventListener('DOMContentLoaded', function () {
// Get all elements with the specified class
var targetElements = document.querySelectorAll('.berocket_better_labels_position span.b_span_text');
// Loop through each element
targetElements.forEach(function (targetElement) {
// Get the number and convert it to a float
var number = parseFloat(targetElement.textContent);
// Check if the number is below 20%
if (number < 20) {
@elias1435
elias1435 / gist:99fbfd4b6b2e3a676fbb0b68aa7180d7
Created January 22, 2024 15:02
Add SVG to allowed file uploads to WordPress
//add SVG to allowed file uploads
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_action('upload_mimes', 'add_file_types_to_uploads');
@elias1435
elias1435 / functions.php
Created February 9, 2024 11:22
WooCommerce: Only Allow 1 Product in the Cart. Place this code in functions.php
add_filter( 'woocommerce_add_to_cart_validation', 'product_only_one_in_cart', 9999 );
function product_only_one_in_cart( $passed ) {
wc_empty_cart();
return $passed;
}
@elias1435
elias1435 / functions.php
Created February 9, 2024 15:34
ACF data in order received page woocommerce. ACF field name is "course_date"
add_action ('woocommerce_order_details_after_order_table', 'action_order_details_after_order_table', 20 );
function action_order_details_after_order_table($order) {
foreach ( $order->get_items() as $item ) {
if ( $course_date = get_field('course_date', $item->get_product_id())) {
printf('<p class="course-date">%s: %s<p>', __("Course Date "), $course_date);
}
}
}
@elias1435
elias1435 / redirect.html
Last active March 13, 2024 19:01
Sometime we need to redirect a url directory. Use this index file to redirect the visitors
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0;url=https://www.exmaple1.com/pages/details/">
<title>Redirecting...</title>
</head>
<body>
<p>If you are not redirected automatically, <a href="https://www.exmaple.com/pages/details1/">click here</a>.</p>
</body>