Skip to content

Instantly share code, notes, and snippets.

View kreamweb's full-sized avatar

Emanuela Antonina Castorina kreamweb

  • Kream di Emanuela Castorina
  • Acicatena (CT) - Italy
View GitHub Profile
@kreamweb
kreamweb / functions.php
Created July 18, 2017 08:13
This code hide the messages to all user that can't earn points.
<?php
if( ! function_exists('YITH_WC_Points_Rewards') ){
add_filter('ywpar_hide_messages', 'ywpar_hide_messages' );
function ywpar_hide_messages( $result ){
if ( ! YITH_WC_Points_Rewards()->is_user_enabled( ) ) {
$result = true;
}
@kreamweb
kreamweb / new_gist_file_0
Last active October 25, 2017 08:36
[Flatsome] Fix where show the cart message inside the single product page is necessary add <div class="col"><?php do_action( 'ywcm_show_message' ); ?></div> in /wp-content/themes/flatsome/woocommerce/single-product/layouts/product.php
<?php
/**
* Moves the message in the single product page
* is necessary add <div class="col"><?php do_action( 'ywcm_show_message' ); ?></div> inside the
* file /wp-content/themes/flatsome/woocommerce/single-product/layouts/product.php of flatsome
* */
if ( defined( 'YITH_YWCM_PREMIUM' ) ) {
add_action( 'template_redirect', 'ywcart_message_single_product' );
function ywcart_message_single_product() {
global $YWCM_Instance;
@kreamweb
kreamweb / functions.php
Created July 12, 2017 09:44
add the other content of email inside the pdf quote
<?php
add_action('yith_ywraq_email_after_raq_table','yith_ywraq_email_after_raq_table');
function yith_ywraq_email_after_raq_table( $order ){
$af4 = yit_get_prop( $order, 'ywraq_other_email_fields', true );
if( ! empty( $af4 ) ){
foreach ( $af4 as $key => $value ) { ?>
<div>
<span><strong><?php echo $key; ?>: </strong></span>
<span><?php echo $value ?></span>
@kreamweb
kreamweb / functions.php
Created July 4, 2017 07:55
Disable ajax search autocomplete on mobile
<?php
if( wp_is_mobile() ){
add_action( 'wp_enqueue_scripts', 'dequeue_script', 11 );
function dequeue_script(){
wp_dequeue_script( 'yith_wcas_jquery-autocomplete' );
wp_dequeue_script( 'yith_autocomplete' );
}
}
@kreamweb
kreamweb / new_gist_file.js
Created June 30, 2017 13:08
copy text in the clipboard
$( document ).on( 'click', '.yith-wcbk-copy-to-clipboard', function ( event ) {
var target = $( this ),
selector_to_copy = target.data( 'selector-to-copy' ),
obj_to_copy = $( selector_to_copy );
if ( obj_to_copy.length > 0 ) {
var temp = $( "<input>" );
$( 'body' ).append( temp );
temp.val( obj_to_copy.html() ).select();
@kreamweb
kreamweb / functions.php
Created June 13, 2017 08:28
how remove the reduction of stock in a renew order
<?php
if ( class_exists( 'YITH_WC_Subscription' ) ) {
add_filter( 'woocommerce_can_reduce_order_stock', 'ywsbs_woocommerce_can_reduce_order_stock', 10, 2 );
function ywsbs_woocommerce_can_reduce_order_stock( $result, $order ) {
$is_a_renew = yit_get_prop( $order, 'is_a_renew' );
return ( $is_a_renew == 'yes' ) ? false : $result;
}
@kreamweb
kreamweb / functions.php
Created June 5, 2017 11:20
Set override shipping off when edit a quote
<?php
add_filter( 'ywraq_order_metabox', 'ywraq_override_shipping_off' );
function ywraq_override_shipping_off( $fields ) {
if ( isset( $fields['ywraq_disable_shipping_method'] ) ) {
$fields['ywraq_disable_shipping_method']['std'] = 'no';
@kreamweb
kreamweb / functions.php
Created May 31, 2017 07:50
Compatibility with Avada
<?php
//Hide add to cart in the loop
add_action('init', 'ywraq_woocommerce_after_shop_loop_item', 0 );
function ywraq_woocommerce_after_shop_loop_item(){
global $avada_woocommerce;
remove_action( 'woocommerce_after_shop_loop_item', array( $avada_woocommerce, 'avada_woocommerce_template_loop_add_to_cart' ), 10 );
}
@kreamweb
kreamweb / functions.php
Created May 29, 2017 12:54
Example to how change the search string
<?php
add_filter('yith_wcas_search_with_like', '__return_true');
add_filter( 'yith_wcas_search_string_manipulation', 'my_yith_wcas_search_string_manipulation' );
function my_yith_wcas_search_string_manipulation( $string ) {
$string = str_replace( '$', '%', trim( $string ) );
$string = str_replace( '.', '%', trim( $string ) );
@kreamweb
kreamweb / new_gist_file.php
Created May 22, 2017 10:30
This code removes all products that are on sale at the moment of creation of coupon.
<?php
add_filter('ywrac_coupon_args','ywrac_coupon_args');
function ywrac_coupon_args( $args ){
$product_on_sale = wc_get_product_ids_on_sale();
if( is_array( $product_on_sale) && !empty( $product_on_sale ) ){
$args['exclude_product_ids'] = implode( ',', $product_on_sale );
}