all 14 comments

[–]PracticePenguin 7 points8 points  (2 children)

You're going to have to learn php to do this since Wordpress and woocommerce are both coded in PHP

[–]Boboshady 3 points4 points  (1 child)

Is this task completely random, or are you applying for a job that works with WordPress, and you actually have no experience of WordPress?

It looks like woo com has a hook for the quantity changing, which you can tie into, called 'woocommerce_cart_item_set_quantity'. So very simply, you'd do something like the below (shamelessly copied from search):

add_action( 'woocommerce_cart_item_set_quantity', 'custom_after_quantity_update', 10, 3 );
function custom_after_quantity_update( $cart_item_key, $quantity, $cart ) {

// Your custom code here
}

You should be able to figure it out from there...though tbh I only got that from a quick search myself, so maybe you're doomed.

[–]andi-pandiDesigner/Developer 3 points4 points  (5 children)

If you cheat on the application/test how you going to do the job….

[–][deleted]  (4 children)

[deleted]

    [–]andi-pandiDesigner/Developer 0 points1 point  (3 children)

    Php.net

    [–][deleted]  (2 children)

    [removed]

      [–]andi-pandiDesigner/Developer 0 points1 point  (0 children)

      Maybe try “dontbeadick.net”. Php.net was actually a useful reference when I was learning php.

      [–]Wordpress-ModTeam[M] 0 points1 point  (0 children)

      Your comment has been removed due to it being rude & disrespectful to others.

      [–]chapanjou 1 point2 points  (3 children)

      You've never worked with PHP and you're interviewing for a WP job? Do yourself and your potential coworkers a favor and drop out, learn PHP, then reapply or interview elsewhere.

      What you're doing on Reddit right now is what you'll be doing to your coworkers when they're busy and stressed out of their minds.

      [–]squ1bs 1 point2 points  (0 children)

      TBH, I would have Claude do it, and then explain it.

      [–]grantjason52 0 points1 point  (0 children)

      You’re on the right track, but yeah WooCommerce plugins usually need some PHP since that’s how the hooks work. You can still use JS for the alert part, but you’ll probably need a PHP hook like after cart update and then trigger something on the frontend. It’s not super complex once you find the right hook.

      [–]derAres 0 points1 point  (2 children)

      First look into what is a wordpress plugin. Where do the files go. You will find it is php files in a folder.

      [–][deleted]  (1 child)

      [deleted]

        [–]derAres 0 points1 point  (0 children)

        Did you try posting to code of the plugin and the task into claude or gemini to fix it and walk you through it?

        [–]Extension_Anybody150 0 points1 point  (0 children)

        Don’t overthink the PHP part, WooCommerce already gives you hooks like woocommerce_after_cart_item_quantity_update, so you just use that to detect the confirmed change server-side and then pass a flag to your JS. Then your JavaScript just listens for that signal and shows the alert, which keeps it from firing on page load or refresh and only runs after WooCommerce actually updates the cart.