Skip to content

Instantly share code, notes, and snippets.

View imanispatel's full-sized avatar
🏠
Working from home

Manish Patel imanispatel

🏠
Working from home
View GitHub Profile
@imanispatel
imanispatel / function.php
Created March 4, 2022 12:54
Woocommerce payment gateway: disable payment gateway by shipping method.
<?php
/**
* Woocommerce disable payment gateway by shipping method.
*/
add_filter( 'woocommerce_available_payment_gateways', 'venus_payment_method_by_shipping' );
function venus_payment_method_by_shipping( $gateways ) {
if( is_admin() ) { // do nothing in /wp-admin
return $gateways;
}
if( is_wc_endpoint_url( 'order-pay' ) ) { // "Pay for order" page
@imanispatel
imanispatel / functions.php
Created June 21, 2021 06:13
Wave Connector: Remove taxes while send invoices
<?php
/**
* Remove Taxes from order
*
* @param array $variables get variables.
* @param int $order_id get order id.
* @return array
*/
function wave_order_variable( $variables, $order_id ) {
$items = array();
@imanispatel
imanispatel / functions.php
Created May 10, 2021 17:01
Modify friends list (add some Specific User role User)
<?php
/**
* Add some Specific User role User
*
* @param array $friend_ids
* @param int $user_id
* @return array
*/
function buc_add_friends_in_list( $friend_ids, $user_id ) {
$users_role = array(
@imanispatel
imanispatel / functions.php
Created January 7, 2021 05:43
Set invoice number when send invoice WC to Wave
<?php
/**
* Set Invoice number as order id
*
* @param array $variables get variables.
* @param int $order_id get order id.
* @return array
*/
function wave_order_variable( $variables, $order_id ) {
@imanispatel
imanispatel / functions.php
Created November 18, 2020 07:42
Change my and friends profile data example: change user display name
<?php
/**
* Update my profile data before get BUC chat
*
* @param array $profile Get my profile data.
* @return array
*/
function buc_update_my_profile_data( $profile ) {
$user_info = get_userdata( $profile['id'] );
$first_name = $user_info->first_name;
@imanispatel
imanispatel / functions.php
Last active August 24, 2020 10:42
Change my and friends profile data example: change profile image
<?php
/**
* Update my profile data before get BUC chat
*
* @param array $profile Get my profile data.
* @return array
*/
function buc_update_my_profile_data( $profile ) {
// If set custom profile image.
$custom_image = 'http://demo.wpvenus.com/bp-better-user-chat/wp-content/uploads/2020/06/Venus.png'; // Custom image url.
@imanispatel
imanispatel / functions.php
Last active August 21, 2020 15:09
Hide BUC chat frame for specific users role if select Specific Users option
<?php
/**
* Hide BUC chat frame if select Specific Users option.
*
* @return void
*/
function buc_hide_chat_frame() {
if( is_user_logged_in() ) {
global $venus_buc;
$settings = $venus_buc->get_settings();
@imanispatel
imanispatel / functions.php
Last active August 21, 2020 15:11
Remove province/state code in guest user data while send to Wave
<?php
/**
* Set custom guest user variable for WooCommerce Wave Connector
* Remove province code in guest user variable.
*
* @param array $variable get variable.
* @param array $order_id get order id.
* @return array
*/
function venus_wc_custom_guest_user_variable( $variable, $order_id ) {
@imanispatel
imanispatel / functions.php
Last active March 17, 2023 02:56
Replace display name with first name & last name in name value
<?php
/**
* Set custom user variable for WooCommerce Wave Connector
* Replace display name with first name & last name in name value
*
* @param array $variables get variables.
* @param array $user_ids get user's id.
* @return array
*/
function custom_customer_variable( $variables, $user_ids ) {
@imanispatel
imanispatel / functions.php
Last active August 21, 2020 15:10
Remove province/state code in user data while send to Wave
<?php
/**
* Set custom user variable for WooCommerce Wave Connector
* Remove province code in user variables.
*
* @param array $variable get variables.
* @param array $user_id get user id.
* @return array
*/
function venus_wc_custom_user_variable( $variable, $user_id ) {