Skip to content

Instantly share code, notes, and snippets.

@pablo-sg-pacheco
Last active October 23, 2018 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pablo-sg-pacheco/1b17054b8a2cb948df6b4d1e38cfb002 to your computer and use it in GitHub Desktop.
Save pablo-sg-pacheco/1b17054b8a2cb948df6b4d1e38cfb002 to your computer and use it in GitHub Desktop.
Product Open Pricing (Name Your Price) for WooCommerce - Add to cart programmatically
<?php
add_action('wp_loaded',function(){
if( is_admin() ){
return;
}
$product_id = 161;
$quantity = 1;
$variation_id = 0;
WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, array(), array(
'alg_open_price' => 99
));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment