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
phpcs --standard=WordPress templates/request-quote-view.php
#hide warning
phpcs --standard=WordPress -n templates/request-quote-view.php
#automation
phpcs --standard=WordPress --report-diff=changes.diff view-quote.php
patch -p0 -ui changes.diff
//only escape
@kreamweb
kreamweb / functions.php
Created March 6, 2020 08:56
**YITH WooCommerce Point of Sale** - Snippet to change the max number of products for search
<?php
add_filter( 'woocommerce_rest_product_object_query', 'yith_pos_extend_post_per_pages', 5, 2 );
function yith_pos_extend_post_per_pages( $args, $request ){
if ( isset( $_GET[ 'queryName' ] ) && 'yith_pos_search' === $_GET[ 'queryName' ] ) {
$args[ 'posts_per_page' ] = 20;
}
return $args;
@kreamweb
kreamweb / functions.php
Last active February 21, 2020 10:25
** YITH Point of Sale for WooCommerce** How add the Sku inside search results
<?php
add_filter( 'woocommerce_rest_prepare_product_object', 'yith_pos_custom_product_response', 20, 3 );
function yith_pos_custom_product_response( $response, $object, $request ) {
$param = $request->get_param( 'queryName' );
if ( $param == 'yith_pos_search' ) {
$result = $response->data;
$result['name'] .= empty($result['sku']) ? '' : ' - ' . $result['sku'];
$response->data = $result;
@kreamweb
kreamweb / functions.php
Last active February 21, 2020 09:32
[POS] Enable options multistock to all products
<?php
add_action( 'init', 'yith_pos_add_meta_to_products' );
function yith_pos_add_meta_to_products() {
$option = get_option( 'yith_pos_stock_product_enabled', 'no' );
if ( $option === 'no' ) {
$products = wc_get_products( array( 'limit' => - 1 ) );
if ( $products ) {
<?php
if (defined('YITH_POS_VERSION')) {
add_action( 'wp_enqueue_scripts', 'yith_pos_add_new_stylesheet', 12 );
function yith_pos_add_new_stylesheet(){
global $yith_pos_styles;
wp_enqueue_style('yith-pos-override-frontend', get_stylesheet_directory_uri().'/pos.css', array('yith-pos-frontend'), YITH_POS_VERSION);
yith_pos_enqueue_style('yith-pos-override-frontend');
}
<?php
if ( ! function_exists( 'yith_pos_customization_barcode_field' ) ) {
add_filter( 'yith_pos_barcode_custom_field', 'yith_pos_customization_barcode_field' );
function yith_pos_customization_barcode_field() {
return "your_barcode_custom_field";
}
}
<?php
if ( ! function_exists( 'yith_pos_customization_css' ) ) {
add_action( 'wp_enqueue_scripts', 'yith_pos_customization_css', 99 );
function yith_pos_customization_css() {
$css = ".yith-pos-product-list__list .product, .yith-pos-product-category-list__list .product-cat{
height: 150px;
}";
wp_add_inline_style( 'yith-pos-frontend', $css );
<?php if ( ! function_exists( 'yith_pos_customization_order_status_to_complete' ) ) {
add_filter( 'woocommerce_payment_complete_order_status', 'yith_pos_customization_order_status_to_complete', 10, 3 );
function yith_pos_customization_order_status_to_complete( $status, $order_id, $order ) {
if ( absint( $order->get_meta( '_yith_pos_order' ) ) ) {
$status = 'completed';
}
return $status;
}
@kreamweb
kreamweb / yith_ywdpd_table_pricing.php
Created June 4, 2019 07:58
Table that show buy x | Price | Discount
<?php
remove_filter( 'woocommerce_'.YITH_WC_Dynamic_Pricing_Frontend()->get_product_filter.'get_price', array( YITH_WC_Dynamic_Pricing_Frontend(), 'get_price' ) );
remove_filter( 'woocommerce_' . YITH_WC_Dynamic_Pricing_Frontend()->get_product_filter . 'variation_get_price', array( YITH_WC_Dynamic_Pricing_Frontend(), 'get_price' ) );
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
if ( $label_table != '' ):
?>
<p class="ywdpd-table-discounts-label"><strong><?php echo $label_table ?></strong>
<?php if ( $until != '' ) {
echo "<span>$until</span>";
<?php
add_filter( 'ywdpd_round_total_price', 'ywdpd_round_price_for_single_product' );
function ywdpd_round_price_for_single_product(){
return false;
}