Skip to content

Instantly share code, notes, and snippets.

View imuhammadshoaib's full-sized avatar
🎯
Focusing

Muhammad Shoaib imuhammadshoaib

🎯
Focusing
View GitHub Profile
@imuhammadshoaib
imuhammadshoaib / functions.php
Created March 15, 2021 13:42 — forked from yratof/functions.php
Getting the Video ID from ACF OEmbed, then using that ID to call in videos without bloat
<?php
/* Parse the video uri/url to determine the video type/source and the video id */
function parse_video_uri( $url ) {
// Parse the url
$parse = parse_url( $url );
// Set blank variables
$video_type = '';
$video_id = '';
@imuhammadshoaib
imuhammadshoaib / cartDiscount.liquid
Created November 12, 2020 10:59 — forked from atikju/cartDiscount.liquid
Shopify - Apply Discount / Coupon / Promo Code on cart page
<div class="cart-promo">
<h2>ENTER A PROMO CODE</h2>
<input type="text" id="devPromo">
<a href="/checkout?discount=none" id="redemDevPromo">Apply Coupon</a>
</div>
<script>
$(document).ready(function(){
//listen to the promo button click
$('#redemDevPromo').on('click', function(event){
//disable the button event
@imuhammadshoaib
imuhammadshoaib / wc-add-additional-information.php
Created August 17, 2020 15:50 — forked from woogists/wc-add-additional-information.php
[Frontend Snippets][Editing product data tabs] Add additional information
/**
* Check if product has attributes, dimensions or weight to override the call_user_func() expects parameter 1 to be a valid callback error when changing the additional tab
*/
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
global $product;
if( $product->has_attributes() || $product->has_dimensions() || $product->has_weight() ) { // Check if product has attributes, dimensions or weight
@imuhammadshoaib
imuhammadshoaib / wc-add-custom-tab.php
Created August 17, 2020 15:50 — forked from woogists/wc-add-custom-tab.php
[Frontend Snippets][Editing product data tabs] Add a custom tab
/**
* Add a custom product data tab
*/
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['test_tab'] = array(
'title' => __( 'New Product Tab', 'woocommerce' ),
@imuhammadshoaib
imuhammadshoaib / wc-custom-tab.php
Created August 17, 2020 15:50 — forked from woogists/wc-custom-tab.php
[Frontend Snippets][Editing product data tabs] Customize a tab
/**
* Customize product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {
$tabs['description']['callback'] = 'woo_custom_description_tab_content'; // Custom description callback
return $tabs;
}
@imuhammadshoaib
imuhammadshoaib / wc-reorder-tabs.php
Created August 17, 2020 15:50 — forked from woogists/wc-reorder-tabs.php
[Frontend Snippets][Editing product data tabs] Reordering product data tabs
/**
* Reorder product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
$tabs['reviews']['priority'] = 5; // Reviews first
$tabs['description']['priority'] = 10; // Description second
$tabs['additional_information']['priority'] = 15; // Additional information third
@imuhammadshoaib
imuhammadshoaib / wc-rename-tabs.php
Created August 17, 2020 15:50 — forked from woogists/wc-rename-tabs.php
[Frontend Snippets][Editing product data tabs] Renaming product data tabs
/**
* Rename product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
$tabs['description']['title'] = __( 'More Information' ); // Rename the description tab
$tabs['reviews']['title'] = __( 'Ratings' ); // Rename the reviews tab
$tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab
@imuhammadshoaib
imuhammadshoaib / wc-remove-tabs.php
Created August 17, 2020 15:49 — forked from woogists/wc-remove-tabs.php
[Frontend Snippets][Editing product data tabs] Remove product data tabs
/**
* Remove product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
@imuhammadshoaib
imuhammadshoaib / function.php
Created December 10, 2019 15:15 — forked from dasbairagya/function.php
short code to get the woocommerce recently viewed products
//short code to get the woocommerce recently viewed products
<?php function custom_track_product_view() {
if ( ! is_singular( 'product' ) ) {
return;
}
global $post;
if ( empty( $_COOKIE['woocommerce_recently_viewed'] ) )
$viewed_products = array();