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
<?php
add_action('wp', function(){ echo '<pre>';print_r($GLOBALS['wp_filter']); echo '</pre>';exit; } );
@kreamweb
kreamweb / request-quote-view.php
Created September 18, 2018 12:13
override the standard template of table list inside the folder woocommerce of your theme
<?php
/**
* This file belongs to the YIT Plugin Framework.
*
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.gnu.org/licenses/gpl-3.0.txt
*/
@kreamweb
kreamweb / functions.php
Created September 13, 2018 13:26
Change the Set Express Checkout Request parameters on YITH PayPal Express Checkout for WooCommerce
<?php
add_filter('yith_paypal_ec_set_express_checkout_request_parameters', 'yith_paypal_ec_set_express_checkout_request_parameters');
function yith_paypal_ec_set_express_checkout_request_parameters( $args ){
$args['NOSHIPPING'] = 2;
$args['ADDROVERRIDE'] = 1;
return $args;
}
@kreamweb
kreamweb / functions.php
Created June 29, 2018 09:43
Fix to remove the conflict between YITH WooCommerce Request a Quote and WooCommerce Subscription when a request of quote is sent.
<?php
/**
* Fix to remove the conflict between YITH WooCommerce Request a Quote and WooCommerce Subscription
* when a request of quote is sent.
*/
add_action('ywraq_before_create_order', 'ywraq_fix_woocommerce_subscription_conflict');
function ywraq_fix_woocommerce_subscription_conflict(){
remove_filter( 'woocommerce_payment_complete_order_status', 'WC_Subscriptions_Order::maybe_autocomplete_order', 10 );
<?php
if ( function_exists( 'ywsbs_get_subscription' ) ) {
add_action( 'ywsbs_renew_subscription', 'ywsbs_renew_subscription_additional_fields', 10, 2 );
function ywsbs_renew_subscription_additional_fields( $renew_order_id, $subscription_id ) {
$subscription = ywsbs_get_subscription( $subscription_id );
$order_id = $subscription->order_id;
$billing_persontype = get_post_meta( $order_id, '_billing_persontype', true );
$billing_cpf = get_post_meta( $order_id, '_billing_cpf', true );
@kreamweb
kreamweb / functions.php
Created June 17, 2018 11:11
use this function to get the points earned in a single order.
<?php
function get_total_user_point( $order ) {
$user_id = false;
if ( !$order instanceof WC_Order ) {
$order = wc_get_order( $order );
}
$user_id = $order->get_user_id();
<?php
add_filter('ywpar_calculate_rewards_discount_max_discount_fixed','ywpar_calculate_rewards_discount_max_discount_fixed', 10, 1);
function ywpar_calculate_rewards_discount_max_discount_fixed( $subtotal ){
return floatval( WC()->cart->get_total('edit') );
}
@kreamweb
kreamweb / functions.php
Created February 2, 2018 08:50
Change the variation price with FROM: ----
<?php
add_filter( 'woocommerce_get_price_html', 'ywsbs_woocommerce_get_variation_price_html', 99, 2 );
add_filter( 'woocommerce_get_variation_price_html', 'ywsbs_woocommerce_get_variation_price_html', 99, 2 );
function ywsbs_woocommerce_get_variation_price_html( $price, $product ){
if ( ! $product->is_type('variable') ){
return $price;
}
$prefix = sprintf('%s: ', __('From', 'iconic'));
@kreamweb
kreamweb / functions.php
Last active January 31, 2018 10:07
Fix for themes that use javascripts for quantity fields
<?php
if ( defined( 'YITH_YWRAQ_PREMIUM' ) ) {
function ywraq_print_my_inline_script() {
?>
<script type="text/javascript" charset="utf-8">
jQuery(document).on('ywraq_table_reloaded', function ($) {
jQuery(document).find( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).addClass( 'buttons_added' ).append( '<input type="button" value="+" class="plus" />' ).prepend( '<input type="button" value="-" class="minus" />' );
<?php
if ( class_exists( 'YITH_YWRAQ_Order_Request' ) ) {
add_action( 'ywraq_add_order_meta', 'ywraq_add_order_meta', 10, 2 );
function ywraq_add_order_meta( $order_id, $raq ) {
if ( ! isset( $raq['other_email_fields'] ) ) {
return;
}