• Resolved egocefalo

    (@egocefalo)


    Hi,

    The strings are being added to all products even if they’re not samples, please check the following example:

    https://ibb.co/tcwZqfb

    Can you please provide with a fix for this error?

    I’m using the string replace snippet as you provided it:

    /* This filter tells the plugin FREE SAMPLES you want to replace PRODUCT_TYPE and SAMPLE_PRICE with something else.
     */
    add_filter( 'wfps_custom_order_meta', __return_true() );
    /**
     * This action will actually output whatever you want in place of the 
     * existing PRODUCT_TYPE and SAMPLE_PRICE lines.
     * In the example below, I've changed the following: 
     * PRODUCT_TYPE -> Product type 
     * SAMPLE_PRICE -> Sample price
     * To add your own custom information enter the following:
     * wc_add_order_item_meta( $itemID, 'Heading text', 'Value text shown after the colon' );
     */
    add_action( 'wfps_custom_order_meta_action', 'fps_custom_meta_action', 10, 2 );
    function fps_custom_meta_action( $itemID, $values ) {
    	$sample = __( 'Sample', 'woo-free-product-sample' );
    	wc_add_order_item_meta( $itemID, 'Product Type', $sample );
    	wc_add_order_item_meta( $itemID, 'Sample Price', (float)$values["sample_price"] );
    }

    Thank you!

    Best regards,

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

    (@egocefalo)

    Hi, still no fix for this problem?

    I hope you can check your snippet or whatever is causing the problem, it should be easy for your team.

    Thank you!

    Plugin Author Scott DeLuzio

    (@scottdeluzio)

    Hi @egocefalo

    This should fix that problem for you:

    /* This filter tells the plugin FREE SAMPLES you want to replace PRODUCT_TYPE and SAMPLE_PRICE with something else.
     */
    add_filter( 'wfps_custom_order_meta', __return_true() );
    /**
     * This action will actually output whatever you want in place of the 
     * existing PRODUCT_TYPE and SAMPLE_PRICE lines.
     * In the example below, I've changed the following: 
     * PRODUCT_TYPE -> Product type 
     * SAMPLE_PRICE -> Sample price
     * To add your own custom information enter the following:
     * wc_add_order_item_meta( $itemID, 'Heading text', 'Value text shown after the colon' );
     */
    add_action( 'wfps_custom_order_meta_action', 'fps_custom_meta_action', 10, 2 );
    function fps_custom_meta_action( $itemID, $values ) {
    	if ( isset( $values['free_sample'] ) ) {
    		$sample = __( 'Sample', 'woo-free-product-sample' );
    		wc_add_order_item_meta( $itemID, 'Product Type', $sample );
    		wc_add_order_item_meta( $itemID, 'Sample Price', (float)$values["sample_price"] );
    	}
    }
    Thread Starter egocefalo

    (@egocefalo)

    Hi @scottdeluzio

    Perfect,

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Product Type – Sample Price strings are being added to all order emails’ is closed to new replies.