Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

<!-- Meta Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
function wc_billing_field_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Billing details' :
$translated_text = __( 'Billing Info', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'wc_billing_field_strings', 20, 3 );
Code Snippet
// Automatically shortens WooCommerce product titles on the main shop, category, and tag pages
// to a set number of characters
function short_woocommerce_product_titles_chars( $title, $id ) {
if ( ( is_shop() || is_product_tag() || is_product_category() ) && get_post_type( $id ) === 'product' ) {
// Kicks in if the product title is longer than 60 characters
if ( strlen( $title ) > 40) {
// Shortens it to 60 characters and adds ellipsis at the end
return substr( $title, 0, 40 ) . '...';
@mohsinworld
mohsinworld / Allow Unsupported File Upload to WordPress Website
Created January 28, 2023 21:48
Ad that code right under "define( 'WP_DEBUG', false );" inside wp-config.php file
define('ALLOW_UNFILTERED_UPLOADS', true);
@mohsinworld
mohsinworld / Update Cart Automatically on Quantity Change
Last active December 29, 2022 10:44
Add this code the functions.php file (CSS to hide update button) Source: https://rudrastyh.com/woocommerce/remove-update-cart-button.html
.woocommerce button[name="update_cart"],
.woocommerce input[name="update_cart"] {
display: none!important;
}
====================================================================
add_action( 'wp_footer', function() {
Created header using this plugin: https://wordpress.org/plugins/header-footer-elementor/
Step 1 – Now edit the above header in Elementor and add a Custom ID to the outermost section (here we are using my-custom-id ).
Step 2 – Now add following custom CSS. You can add it to the customizer under the ‘Additional CSS’ section or use
any external plugin that provides an area to add custom CSS.
#custom-sticky-section.elementor-section{
position: fixed;
left: 0;
[timed-content-server show="2022-08-30 19:35 UTC"]Show content after August 30, 2022 and 7:35 PM UTC Timezone[/timed-content-server]
[timed-content-server hide="2022-08-30 19:35 UTC"]Hide content after August 30, 2022 and 7:35 PM UTC Timezone[/timed-content-server]
@mohsinworld
mohsinworld / WooCommerce Add to Cart Link
Created August 23, 2022 14:13
Add this link after the domain. Example: yourdomain.com/?add-to-cart=25 where 25 is the product ID
add_action( 'template_redirect', 'bhww_ssl_template_redirect', 1 );
function bhww_ssl_template_redirect() {
if ( is_ssl() && ! is_admin() ) {
if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
wp_redirect( preg_replace( '|^https://|', 'http://', $_SERVER['REQUEST_URI'] ), 301 );
exit();