Skip to content

Instantly share code, notes, and snippets.

View digitalchild's full-sized avatar

Jamie Madden digitalchild

View GitHub Profile
@digitalchild
digitalchild / functions.php
Created June 25, 2021 06:40
Re-enable woocommerce_before_main_content for the wc-product-archive widget for elementor and WC Vendors Pro
<?php
// Elementor does not include woocommerce_before_main_content in their wc-product-archive widget
// WC Vendors users the woocommerce_before_main_content to hook into to display the vendor store headers
// The following snippet re-adds the required actions for WC Vendors
// @source - https://github.com/elementor/elementor/issues/5574
// Add the woocommerce_before_main_content to the elementor wc-archive-products widget
add_action( 'elementor/widget/render_content', function( $content, $widget ) {
@digitalchild
digitalchild / functions.php
Created June 17, 2021 09:23
Update the vendor shipping shipping package title in WC Vendors Pro
<?php
add_filter( 'wcv_vendor_shipping_package_title', 'wcv_change_package_title', 10, 4 );
function wcv_change_package_title( $title, $count, $package, $vendor_sold_by ){
$vendor_sold_by = WCV_Vendors::get_vendor_sold_by( $package['vendor_id'] );
$title = sprintf( __( 'Modes de livraison des articles ( %s )', 'wcvendors-pro' ), $vendor_sold_by );
return $title;
}
@digitalchild
digitalchild / functions.php
Last active June 17, 2021 03:12
remove mark received button from orders my-accounts
<?php
add_filter( 'woocommerce_my_account_my_orders_actions', 'remove_mark_received' );
function remove_mark_received( $actions ){
if (array_key_exists('wcv-mark-order-received', $actions ) ){
unset($actions['wcv-mark-order-received']);
}
return $actions;
}
@digitalchild
digitalchild / pro-vendor-list.php
Last active June 12, 2021 02:47
Add vendor address details to the vendor list template for WC Vendors Pro
<?php
/**
* The Template for displaying a vendor in the vendor list shortcode
*
* Override this template by copying it to yourtheme/wc-vendors/front
*
* @package WCVendors_Pro
* @since 1.2.3
* @version 1.6.3
*/
@digitalchild
digitalchild / functions.php
Created June 8, 2021 04:31
Override WC Vendors Pro shipping method label in cart and checkout
<?php
add_filter( 'woocommerce_cart_shipping_method_full_label', 'wcv_override_vendor_shipping_label', 10, 2 );
function wcv_override_vendor_shipping_label( $label, $method ){
$label = 'Livraison Standard';
$has_cost = 0 < $method->cost;
$hide_cost = ! $has_cost && in_array( $method->get_method_id(), array( 'free_shipping', 'local_pickup' ), true );
if ( $has_cost && ! $hide_cost ) {
if ( WC()->cart->display_prices_including_tax() ) {
@digitalchild
digitalchild / function.php
Created June 3, 2021 11:14
Disable the add to cart button on the single product page in javascript
<?php
// disable add to cart with js
add_action( 'wp_footer', 'disable_somebutton_js' );
function disable_somebutton_js(){
// Bail if this isn't the single product page
if ( ! is_single() ) return;
global $product;
@digitalchild
digitalchild / logger.php
Created June 3, 2021 05:17
Output class file and class name
<?php
public static function log( $data = '', $prefix = '' ) {
// phpcs:disable
$trace = debug_backtrace( false, 2 );
$caller = ( isset( $trace[1]['class'] ) ) ? $trace[1]['class'] : basename( $trace[1]['file'] );
if ( is_array( $data ) || is_object( $data ) ) {
if ( $prefix ) {
error_log( '===========================' );
@digitalchild
digitalchild / functions.php
Last active May 21, 2021 10:03
Add an ACF field after the subject field on the WC Vendors Contact Widget
<?php
// Add the property reference as a hidden field on the single product page.
add_action( 'wcv_quick_contact_after_subject', 'add_acf_fields' );
function add_acf_fields(){
global $post;
if ( is_single() ){
$referencia = get_field ('referencia', $post->ID ); //reference is my ACF field
$tipo_de_anuncio = get_field ('tipo_de_anuncio', $post->ID ); //tipo_de_anuncio is my ACF field
WC_Vendors::log( $tipo_de_anuncio );
@digitalchild
digitalchild / functions.php
Created May 13, 2021 03:16
Add a checkbox to the product page and save itr
<?php
add_action( 'wcv_after_product_type', 'wcv_checkbox_check' );
function wcv_checkbox_check( $object_id ){
$value = get_post_meta( $object_id, 'wcv_custom_product_checkbox3', true );
WCVendors_Pro_Form_Helper::input( array(
'id' => 'wcv_custom_product_checkbox3',
'label' => __( 'Personalisation', 'wcvendors-pro' ),
'type' => 'checkbox',
'desc_tip' => true,
@digitalchild
digitalchild / functions.php
Created April 23, 2021 05:13
Enable Full WP_Editor on Product Fields in WC Vendors Pro
<?php
add_filter( 'wcv_product_description_editor_settings', 'wcv_full_editor' );
add_filter( 'wcv_product_short_description_editor_settings', 'wcv_full_editor' );
function wcv_full_editor( $settings ){
$settings['teeny'] = false;
return $settings;
}