🏃♂️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Track recently viewed products | |
| function track_recently_viewed_products() { | |
| if (is_singular('product')) { | |
| $product_id = get_the_ID(); | |
| // Get current list from cookie | |
| $recently_viewed = isset($_COOKIE['recently_viewed_products']) ? explode(',', $_COOKIE['recently_viewed_products']) : []; | |
| // Remove current product if already exists | |
| if (($key = array_search($product_id, $recently_viewed)) !== false) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Show live stock countdown message | |
| function rh_live_stock_countdown_message() { | |
| global $product; | |
| // Set the threshold for low stock | |
| $stock_threshold = 5; | |
| // For variable products | |
| if ( $product->is_type( 'variable' ) ) { | |
| echo '<div id="rh-stock-count-message"></div>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 1. Add a new tab to product pages | |
| add_filter( 'woocommerce_product_tabs', function( $tabs ) { | |
| $tabs['qa_tab'] = [ | |
| 'title' => 'Q&A', | |
| 'priority' => 50, | |
| 'callback' => 'render_product_qa_tab', | |
| ]; | |
| return $tabs; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('woocommerce_thankyou', 'gcr_show_guest_reminder_notice'); | |
| function gcr_show_guest_reminder_notice($order_id) { | |
| if (is_user_logged_in()) { | |
| return; // Logged-in users don't need the reminder | |
| } | |
| $order = wc_get_order($order_id); | |
| if (!$order) return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Add Mini Cart to header via hook | |
| add_action('wp_head', 'rashed_enqueue_mini_cart_styles'); | |
| add_action('wp_footer', 'rashed_enqueue_mini_cart_script'); | |
| function rashed_enqueue_mini_cart_styles() { | |
| ?> | |
| <style> | |
| .rashed-mini-cart { | |
| position: relative; | |
| display: inline-block; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Save cart contents to cookie on page unload | |
| function rashed_save_cart_to_cookie() { | |
| if ( is_admin() || is_cart() || is_checkout() ) return; | |
| ?> | |
| <script type="text/javascript"> | |
| window.addEventListener('beforeunload', function () { | |
| if (typeof wc_cart_params === 'undefined') return; | |
| fetch(wc_cart_params.ajax_url + '?action=rashed_get_cart_contents', { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Add Buy Now button next to Add to Cart | |
| add_action('woocommerce_after_add_to_cart_button', 'one_click_checkout_button'); | |
| function one_click_checkout_button() { | |
| global $product; | |
| if ($product->is_type('simple')) { | |
| $url = esc_url(add_query_arg([ | |
| 'one_click_checkout' => 'yes', | |
| 'product_id' => $product->get_id() | |
| ], home_url())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1. Variables and Data Types | |
| name = "Rashed" | |
| age = 25 | |
| is_student = True | |
| print("Name:", name) | |
| print("Age:", age) | |
| print("Is Student:", is_student) | |
| print("Type of name:", type(name)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from PIL import Image | |
| # Input and output directories | |
| INPUT_FOLDER = "input_images" | |
| OUTPUT_FOLDER = "output_images" | |
| NEW_SIZE = (4000, 2250) # Set your desired width and height | |
| # Create output folder if it doesn't exist | |
| os.makedirs(OUTPUT_FOLDER, exist_ok=True) |
NewerOlder