Skip to content

Instantly share code, notes, and snippets.

View vagelisp's full-sized avatar
👋

Vagelis P. vagelisp

👋
View GitHub Profile
@vagelisp
vagelisp / functions.php
Last active August 4, 2023 13:37
WooCommerce - Function to restrict users from placing multiple orders per hour
<?php
// Function to restrict users from placing multiple orders per hour
function restrict_orders_per_hour_product_notice() {
// Get the current user's ID.
$user_id = get_current_user_id();
// Retrieve all orders for the current user.
$orders = wc_get_orders( array(
'numberposts' => -1,
'orderby' => 'date',
@vagelisp
vagelisp / functions.php
Last active April 20, 2021 08:08 — forked from qstudio/get_post_by_meta.php
WordPress / Get Post by Meta Value
/**
* Get Post object by post_meta query
*
* @use $post = get_post_by_meta( array( 'meta_key' => meta_name, 'meta_value' => value, 'post_type' => post_type, 'post_per_page' => post_per_page ) )
* @since 1.0.5
* @return Object WP post object
*/
function get_post_by_meta( $args = array() ) {
$args = (object) wp_parse_args( $args );
$args = array(
@vagelisp
vagelisp / custom.js
Last active July 26, 2019 12:29
Hijack elementor's logo link with JQ
jQuery( document ).on( 'click', '.elementor-widget-theme-site-logo, .custom-logo', function(e) {
e.preventDefault();
window.location.href = "https://new URL";
});
/**
* Exclude products from a particular category on the shop page
*/
function hide_products_in_unc( $q ) {
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'uncategorized' ),
'operator' => 'NOT IN'
@vagelisp
vagelisp / custom.js
Last active June 8, 2019 21:21
JS for Aggelos
jQuery(document).ready(function() {
jQuery("[id^=quform_10_218_]").change(function(event) {
jQuery("[id^=quform_10_1]")
.find("option:selected")
.removeAttr("selected");
jQuery("[id^=quform_10_1]").val("");
jQuery("[id^=quform_10_1]").change();
jQuery("[id^=quform-form]").closest('form').trigger("reset");
});
});
@vagelisp
vagelisp / functions.php
Last active June 7, 2019 22:24
Merge WC product tabs ( Description + Additional info )
add_filter( 'woocommerce_product_tabs', 'vagelis_dev_merge_tabs', 99 );
function vagelis_dev_merge_tabs( $tabs ) {
$tabs['description']['callback'] = function() {
global $product;
the_content();
do_action( 'woocommerce_product_additional_information', $product );
};
unset( $tabs['additional_information'] );
return $tabs;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
<?php global $post;?>
<?php
$columns = (isset($columns)) ? $columns : '';
$aff_link = (isset($aff_link)) ? $aff_link : '';
if(!isset($disable_btn)){
$disable_btn = (rehub_option('rehub_enable_btn_recash') == 1) ? 0 : 1;
}
$gridtype = (isset($gridtype)) ? $gridtype : '';
if(rehub_option('disable_btn_offer_loop')){
function post_change_expired_function_new () {
if (is_admin()):
return;
endif;
if (is_single()):
$offer_coupon_date = get_post_meta( $post->ID, 'rehub_offer_coupon_date', true );
$timestamp1 = strtotime($offer_coupon_date) + 86399;
$seconds = $timestamp1 - (int)current_time('timestamp',0);
$days = floor($seconds / 86400);
$seconds %= 86400;
//remove the text {PHP}
add_filter( 'woocommerce_product_add_to_cart_text', 'change_text_woo' );
function change_text_woo() {
return;
}
//add the icon {CSS}
a.button.product_type_simple.add_to_cart_button.ajax_add_to_cart:after {
content: "\f111";
font-family: dashicons;
add_action( 'woocommerce_cart_calculate_fees','custom_tax_surcharge_for_retailers', 10, 1 );
function custom_tax_surcharge_for_retailers( $cart ) {
if ( is_admin() && ! defined('DOING_AJAX') ) return;
global $woocommerce;
if ( isset( $_POST['post_data'] ) ) {
parse_str( $_POST['post_data'], $post_data );
} else {
$post_data = $_POST;
}