• Resolved ilyapokrov

    (@ilyapokrov)


    I need to make changes to plugins/woocommerce/includes/wc-product-functions.php file
    But when the plugin is updated, everything will break. How can I change it using a child theme?
    Some other woocommerce files (such as archive-product.php, content-product.php) work fine in my child theme. But wc-product-functions.php doesn’t want to.
    What can I do?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ilyapokrov

    (@ilyapokrov)

    To be more precise, here is the function that I need to overwrite.

    function wc_placeholder_img( $size = 'woocommerce_thumbnail', $attr = '' ) {
    	$dimensions        = wc_get_image_size( $size );
    	$placeholder_image = get_option( 'woocommerce_placeholder_image', 0 );
    
    	$default_attr = array(
    		'class' => 'woocommerce-placeholder wp-post-image',
    		'alt'   => __( 'Placeholder', 'woocommerce' ),
    	);
    
    	$attr = wp_parse_args( $attr, $default_attr );
    
    	if ( wp_attachment_is_image( $placeholder_image ) ) {
    		$image_html = wp_get_attachment_image(
    			$placeholder_image,
    			$size,
    			false,
    			$attr
    		);
    	} else {
    		$image      = wc_placeholder_img_src( $size );
    		$hwstring   = image_hwstring( $dimensions['width'], $dimensions['height'] );
    		$attributes = array();
    
    		foreach ( $attr as $name => $value ) {
    			$attribute[] = esc_attr( $name ) . '="' . esc_attr( $value ) . '"';
    		}
    
    		$image_html = '<img src="' . esc_url( $image ) . '" ' . $hwstring . implode( ' ', $attribute ) . '/>';
    	}
    
    	return apply_filters( 'woocommerce_placeholder_img', $image_html, $size, $dimensions );
    }

    How can i do this?

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi there ??

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers!

    Plugin Support Damianne P (a11n)

    (@drwpcom)

    Hi @ilyapokrov. It looks like no one has been able to help you here. I recommend visiting one of the other resources shared above for help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Modify wc-product-functions.php’ is closed to new replies.