Skip to content

Instantly share code, notes, and snippets.

@alphasider
alphasider / woo_add_product_programmatically.php
Created September 21, 2020 11:23
Add woocommerce product programmaticaly (with attributes)
<?php
/**
* SOURCE: https://stackoverflow.com/questions/52937409/create-programmatically-a-product-using-crud-methods-in-woocommerce-3
*/
/* THE CODE FUNCTION */
// Custom function for product creation (For Woocommerce 3+ only)
function create_product( $args ){
global $woocommerce;
@leepeterson
leepeterson / ajax-endpoint.js
Created February 21, 2020 06:33 — forked from jtsternberg/ajax-endpoint.js
Proof of concept for avoiding admin-ajax for ajax callback requests. Also see Thomas Griffin's excellent post: https://thomasgriffin.io/a-creative-approach-to-efficient-and-scalable-wordpress-api-endpoints/ AND Josh Pollock's excellent post: http://torquemag.io/improved-wordpress-front-end-ajax-processing/
jQuery(document).ready(function($){
$('body').on( 'click', '.some-button', function(){
$.ajax( ajax_endpoint_data.api_url, {
type : 'POST',
dataType : 'json',
data : {
action: 'ajax_action',
some_data: 'some_value'
}