Skip to content

Instantly share code, notes, and snippets.

View FrancoStino's full-sized avatar
🌞

Davide Ladisa FrancoStino

🌞
View GitHub Profile
@FrancoStino
FrancoStino / Visit count into product page and into custom column inside admin product page called "Views" (visite) - Woocommerce.php
Last active July 2, 2021 13:46
Visit count into product page and into custom column inside admin product page called "Views" (visite) - Woocommerce
<?
/*
* Visit count into product page and into custom column inside admin product page called "Views" (visite) - Woocommerce
*/
add_action('wp', function() {
global $post;
@FrancoStino
FrancoStino / Disable purchase and add to cart specific product with checkbox into inventory setting product admin page and replace with required inquiry (Richiedi un preventivo) contact form.php
Last active September 1, 2022 10:36
Disable purchase and add to cart specific product with checkbox into inventory setting product admin page and replace with required inquiry (Richiedi un preventivo) contact form
<?php
/*
* Disable purchase and add to cart specific product with checkbox into inventory setting product admin page and replace with required inquiry (Richiedi un preventivo) contact form
*/
// Add checkbox
function action_woocommerce_product_options_inventory_product_data() {
// Checkbox
woocommerce_wp_checkbox( array(
@FrancoStino
FrancoStino / Add Catalog mode ( disable single product purchase ) through new stock status avaibility Woocommerce.php
Last active July 10, 2021 10:14
Add Catalog mode ( disable single product purchase ) through new stock status avaibility Woocommerce
<?
/*
* Add Catalog mode ( disable single product purchase ) through new stock status avaibility Woocommerce
*/
// Add new stock status options
function filter_woocommerce_product_stock_status_options( $status ) {
// Add new statuses
$status['catalogo'] = __( 'Catalogo / Vetrina', 'woocommerce' );
@FrancoStino
FrancoStino / check-and-redirect-to-login-before-checkout-force-login-and-registration-sign-up-sign-in-woocommerce.php
Last active October 11, 2023 15:10
Check and redirect to login before checkout - Force login and registration sign up sign in - Woocommerce
<?php
/*
* WooCommerce check and redirect to login before checkout
*/
add_action('template_redirect', 'check_if_logged_in');
function check_if_logged_in()
{
$pageid = get_option('woocommerce_checkout_page_id');
@FrancoStino
FrancoStino / discount-as-fee-on-cart-at-first-order-exclude-product-on-sale-and-if-is-applied-a-coupon-disable-fee-version-update.php
Last active September 27, 2022 08:13
Discount as fee on cart at first order exclude product on sale and if is applied a coupon disable fee - Version Update
<?php
/**
* Discount as fee on cart at first order exclude product on sale and if is applied a coupon disable fee - Version Update
*/
add_action('woocommerce_cart_calculate_fees' , 'custom_discount', 10, 1);
function custom_discount( $cart ){
if ( is_admin() && ! defined( 'DOING_AJAX' ) || ! is_user_logged_in() )
@FrancoStino
FrancoStino / Save custom post meta into attributes and set by default multiple attribute term into the product - Woocommerce.php
Last active November 4, 2021 08:48
Save custom post meta into attributes and set by default multiple attribute term into the product - Woocommerce
<?
/*
* Save custom post meta into attributes and set by default multiple attribute term into the product - Woocommerce
*/
function update_post_meta_subito($product_id)
{
$taxonomy = 'pa_brand'; // The taxonomy
@FrancoStino
FrancoStino / index.php
Last active September 30, 2023 19:00
Call and include PHP files in Wordpress theme
<?php
require ('functions/???.php');
@FrancoStino
FrancoStino / Save custom post meta into attribute and set by default attribute term into the product - Woocommerce.php
Last active May 30, 2023 11:09
Save custom post meta into attribute and set by default attribute term into the product - Woocommerce
<?php
/*
* Save custom post meta into attribute and set by default attribute term into the product - Woocommerce
*/
function danea_produttore_meta($product_id)
{
// Verifica se l'ordine è in fase di elaborazione
if (is_checkout() && !is_wc_endpoint_url('order-received')) {
@FrancoStino
FrancoStino / Convert "Draft" post to "Publish" after save post.php
Created August 15, 2021 09:38
Convert "Draft" post to "Publish" after save post
<?
/*
* Convert "Draft" post to "Publish" after save post
*/
add_action( 'save_post', 'change_post_status', 20, 2 );
function change_post_status( $post_id ){
$my_post = array(
'ID' => $post_id,
@FrancoStino
FrancoStino / Hide the Company Name Field from the Checkout Page.php
Created September 20, 2021 12:22
Hide the Company Name Field from the Checkout Page
<?
/**
* @ snippet Hide the Company Name Field from the Checkout Page
*/
add_filter( 'woocommerce_checkout_fields' , 'remove_company_name' );