Skip to content

Instantly share code, notes, and snippets.

View racmanuel's full-sized avatar
💡
Making new things!

Manuel Ramirez Coronel racmanuel

💡
Making new things!
View GitHub Profile
@racmanuel
racmanuel / functions.php
Created November 29, 2023 22:58 — forked from nayemDevs/functions.php
Add new field on vendor product upload form in Dokan
/*
* Adding extra field on New product popup/without popup form
*/
add_action( 'dokan_new_product_after_product_tags','new_product_field',10 );
function new_product_field(){ ?>
<div class="dokan-form-group">
<?php
/**
* Put this into your functions.php of your child-theme or custom plugin
* you can create the role with wp-cli by running `wp shell` and running the command:
* add_role('merchant','Merchant',array('read' => true, 'delete_posts' => false) );
*/
/**
* Step #1: create the field used to store the new sale_price for product_variation and for products
*/
@racmanuel
racmanuel / sync_acf_post_title.php
Created December 7, 2022 21:40 — forked from rveitch/sync_acf_post_title.php
Update WordPress post title from an ACF field value on save. (Advanced Custom Fields)
<?php
/**
* Update Post Title from an ACF field value on post save.
*
* Triggers on save, edit or update of published posts.
* Works in "Quick Edit", but not bulk edit.
*/
function sync_acf_post_title($post_id, $post, $update) {
$acf_title = get_field('my_acf_field_name', $post_id); // NOTE: enter the name of the ACF field here
@racmanuel
racmanuel / woo-update-product-stock-qty.php
Created November 25, 2022 19:20 — forked from stuart-lambon/woo-update-product-stock-qty.php
Updates WooCommerce product stock quantity programmatically. $sku and $qty variables need to be filled.
<?php
$sku = 'ITEM001';
$qty = 1;
// Get product_id from SKU — returns null if not found
$product_id = wc_get_product_id_by_sku( $sku );
// Process if product found
if ( $product_id != null ) {
@racmanuel
racmanuel / one-million-posts.md
Created October 31, 2022 23:26 — forked from xhrix/one-million-posts.md
One Million Posts - Wordpress

One million posts

Let's create one million posts to see the performance of a Wordpress site.

Creation of a post

The purpose of this document is to find out what is the underlying data that gets modified in a wordpress database when a post with an image are created.

What I did

<?php
/*
Plugin Name: Add Gift Card as Custom Product Type
Description: A simple demo plugin on how to add Gift Card as your custom product type
Author: Bhavik Kiri
Version: 1.0
*/
add_action( 'plugins_loaded', 'wcpt_register_gift_card_type' );
<?php
/**
*
* You can find the complete tutorial for this here:
* https://pluginrepublic.com/woocommerce-custom-fields
*
* Alternatively, check out the plugin
* https://pluginrepublic.com/wordpress-plugins/woocommerce-product-add-ons-ultimate/
*
@racmanuel
racmanuel / cf7_external_db2018.php
Created September 27, 2022 17:01 — forked from jc4316son/cf7_external_db2018.php
Contact Form 7 to External DB 2018
<?php
/*
Plugin Name: Contact Form 7 to External DB
Plugin URI:
Description: This plugin uses the wpcf7_before_send_mail hook to post a specific form to an external database. Upon use the details for your external database will need to be entered. Private use only.
Author:
Version: 0.2
Author URI:
*/
@racmanuel
racmanuel / functions.php
Created August 2, 2022 15:52
remplace a list field of gravity forms with select and get the results from external api
<?php
add_filter( 'gform_column_input_2_15_1', 'set_column', 10, 5 );
function set_column( $input_info, $field, $column, $value, $form_id ) {
$request = wp_remote_get( 'https://pippinsplugins.com/edd-api/products' );
if( is_wp_error( $request ) ) {
return false; // Bail early
}
$body = wp_remote_retrieve_body( $request );
<?php
add_action( 'woocommerce_before_single_product', 'bbloomer_show_video_not_image' );
function bbloomer_show_video_not_image() {
// Do this for product ID = 282 only
if ( is_single( '282' ) ) {
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );