Skip to content

Instantly share code, notes, and snippets.

View Roshanb54's full-sized avatar
🏠
Working From Home

Roshan Banstola Roshanb54

🏠
Working From Home
View GitHub Profile
add_action( 'woocommerce_register_form_start', 'prefix_add_name_woo_account_registration' );
function prefix_add_name_woo_account_registration() {
?>
<p class="form-row form-row-first">
<label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
</p>
<?php
// To add custom data above add to cart button in woocommerce
// step 1
add_action('wp_ajax_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
add_action('wp_ajax_nopriv_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
function wdm_add_user_custom_data_options_callback()
{
//Custom data - Sent Via AJAX post method
$product_id = $_POST['id']; //This is product ID
$custom_data_1 = $_POST['custom_data_1']; //This is User custom value sent via AJAX
Step 1: Add Data in a Custom Session, on ‘Add to Cart’ Button Click
<?php
add_action('wp_ajax_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
add_action('wp_ajax_nopriv_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
function wdm_add_user_custom_data_options_callback()
{
//Custom data - Sent Via AJAX post method
$product_id = $_POST['id']; //This is product ID
$user_custom_data_values = $_POST['user_data']; //This is User custom value sent via AJAX
* Disable payment gateways for shipping methods
* Filter payment gatways
*/
function my_custom_available_payment_gateways( $gateways ) {
$chosen_shipping_rates = WC()->session->get( 'chosen_shipping_methods' );
// When 'local delivery' has been chosen as shipping rate
if ( in_array( 'local_delivery', $chosen_shipping_rates ) ) :
// Remove bank transfer payment gateway
unset( $gateways['bacs'] );
endif;
<?php
get_header();
$al_cat_slug = get_queried_object()->slug;
$al_cat_name = get_queried_object()->name;
?>
<h2><?php echo $al_cat_name; ?></h2>
<?php
$al_tax_post_args = array(
'post_type' => 'Your Post Type', // Your Post type Name that You Registered
@Roshanb54
Roshanb54 / README.md
Created April 6, 2021 09:09 — forked from ControlledChaos/README.md
Change the default WordPress post name to News and replace the Dashicon.

Change Default Posts to News

WordPress Snippet