SNIPPET PARA CAMBIAR PRECIO SEGUN LA HORA

add_filter(‘woocommerce_get_price’, ‘change_price_according_to_time’, 10, 2);

function change_price_according_to_time($price, $product) {

date_default_timezone_set(‘America/Mexico_City’); // Cambia esto a tu zona horaria
$hour = date(‘H’); //Obtenemos la hora actual

if ($hour >= 9 && $hour <= 18) { // Define tus propios horarios
return $price; // El precio normal durante las horas especificadas
} else {
return $price * 0.9; // Un 10% de descuento fuera de las horas especificadas
}
}

Entradas relacionadas

5 comentarios

  • Hi there! Would you mind if I share your blog with
    my twitter group? There’s a lot of folks that I think would really appreciate your content.
    Please let me know. Thanks

  • Unquestionably believe that which you stated.
    Your favorite reason appeared to be on the web the easiest thing to be aware of.
    I say to you, I certainly get irked while people consider worries that they plainly don’t know about.
    You managed to hit the nail upon the top as well as
    defined out the whole thing without having side effect , people could take a signal.
    Will likely be back to get more. Thanks

  • It’s awesome to go to see this web site and reading the
    views of all colleagues on the topic of this post, while I am also eager of getting familiarity.

  • Howdy! This is kind of off topic but I need some help from an established
    blog. Is it hard to set up your own blog? I’m not very
    techincal but I can figure things out pretty quick.

    I’m thinking about setting up my own but I’m not sure where to start.
    Do you have any tips or suggestions? With thanks

  • I was wondering if you ever considered changing the layout of your site?
    Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people could connect with it
    better. Youve got an awful lot of text for only having 1 or 2 pictures.

    Maybe you could space it out better?

Deja tu comentario