Skip to content

Instantly share code, notes, and snippets.

View gonzalesc's full-sized avatar

Alexander gonzalesc

View GitHub Profile
@gonzalesc
gonzalesc / create_custom_endpoint_to_wp.php
Created February 28, 2025 07:32
Create custom endpoint to WordPress
<?php
/**
* Create custom RestAPI
* @link http://wpplugins.local/wp-json/letsgo/v1/activatePlugin
* @return void
*/
add_action( 'rest_api_init', function (): void {
register_rest_route(
'letsgo/v1', '/activatePlugin', [
@gonzalesc
gonzalesc / wc_multiple_products_to_cart.php
Created March 25, 2025 06:25
Add multiple products to cart in the URL in WooCommerce
<?php
add_action( 'wp_loaded', 'maybeAddMultipleProductToCart', 25 );
/**
* Add Multiple products by URL
* @example
* simple: http://wpplugins.local/cart/?add-to-cart=27,28
* variation : http://wpplugins.local/cart/?add-to-cart=208,32
* @return void
* @throws Exception