Skip to content

Instantly share code, notes, and snippets.

View zoogits's full-sized avatar

Zoo Studio zoogits

View GitHub Profile
@passatgt
passatgt / add-to-cart-form-shortcode.php
Created August 26, 2021 20:11
WooCommerce Add To Cart Form Shortcode that supports variable products too
add_shortcode( 'add-to-cart-form', function($atts) {
global $post;
//Get shortcode attributes
$a = shortcode_atts( array(
'id' => 0
), $atts );
//Find the product and set it to global
$product_data = get_post( $a['id'] );