Forum Replies Created

Viewing 9 replies - 31 through 39 (of 39 total)
  • Thread Starter dllive

    (@dllive)

    GDPR says something about only holding data for as long as you need it. I have an online florist website. When a user places an order on the website I get emailed their address etc… I then send them their order. After that I dont need to hold on to their details. At this point I should delete the email (with their details) and the order record in Woocommerce? Or should I just – once a month – delete all orders for that month. Or should I just not delete anything? πŸ™‚
    I will consult a lawyer, Im just trying to cover the basics first. (Adding a cookie notification etc…)

    Thread Starter dllive

    (@dllive)

    AH! Thanks so much lorro – its now working!!! πŸ™‚

    Thread Starter dllive

    (@dllive)

    Hi guys, just reopening this.

    Ive *almost* got this working. My code in my functions.php:

    add_filter( 'woocommerce_email_order_meta_fields', 'woocommerce_email_order_meta_fields_func', 10, 3 );
    function woocommerce_email_order_meta_fields_func( $fields, $sent_to_admin, $order ) {
    
    	$fields['card_message'] = array(
    		'label' => __( 'Enter your message to appear on the card', 'woocommerce' ),
    		'value' => wptexturize( get_post_meta( $order->id, 'card_message', true ) ),
    	);
    	
    	$fields['delivery_instructions'] = array(
    		'label' => __( 'Delivery date' ),
    		'value' => get_post_meta( $order->id, 'order_delivery_date', true ),
    	);
    
    	//... more meta fields goes here
    
    	return $fields;
    }
    
    add_action( 'woocommerce_email_after_order_table', 'woocommerce_email_after_order_table_func' );
    function woocommerce_email_after_order_table_func( $order ) {
    	?>
    
    	<h3>Additional information</h3>
    	<table>
    		<tr>
    			<td>Card message: </td>
    			<td><?php echo wptexturize( get_post_meta( $order->id, 'card_message', true ) ); ?></td>
    		</tr>
    		<tr>
    			<td>Order delivery date: </td>
    			<td><?php echo wptexturize( get_post_meta( $order->id, 'order_delivery_date', true ) ); ?></td>
    		</tr>
    	</table>
    
    	<?php
    }

    This displays the html in my emails, BUT it doesnt pass through the 2 variables.

    I feel Im almost there, just need to get those 2 variables to display in the emails.

    Thanks so much for your help πŸ™‚

    Thread Starter dllive

    (@dllive)

    Hi Dustin. Im adding it to my theme’s functions.php file.

    Just to clarify: I need to display the 2 new fields on both the New Order emails and the Failed Order emails.

    Thread Starter dllive

    (@dllive)

    Hmm, I just tried your code and still nothing. Am I right in thinking that it should show up in the Failed Email too? Or is it just going to work in the New Order emails?

    What would the code be if I used an action (presumably “woocommerce_email_order_meta_fields” ?)

    Sorry. Thanks for your continued assistance. :/

    Thread Starter dllive

    (@dllive)

    So sorry Michael, as you can tell, Im not the most experienced developer. πŸ™‚

    So Ive changed my code to:

    add_filter( 'woocommerce_email_order_meta', 'custom_woocommerce_email_order_meta', 10, 3 );
    
    function custom_woocommerce_email_order_meta( $fields, $sent_to_admin, $order ) {
        $fields['meta_key'] = array(
            'label' => __( 'Enter your message to appear on the card' ),
            'value' => get_post_meta( $order->id, 'card_message', true ),
        );
        return $fields;
    }

    How would I pass the card_message variable to the email?

    Thread Starter dllive

    (@dllive)

    Thanks.

    The client doesnt want to pay for the Checkout Field Editor plugin. πŸ™

    Im not sure how to “…hook into the right location”

    Ive tried the following which I found on a forum post, but it doesnt work:

    add_filter( 'woocommerce_email_order_meta_fields', 'custom_woocommerce_email_order_meta_fields', 10, 3 );
    
    function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
        $fields['meta_key'] = array(
            'label' => __( 'Enter your message to appear on the card' ),
            'value' => get_post_meta( $order->id, 'card_message', true ),
        );
        return $fields;
    }
    Thread Starter dllive

    (@dllive)

    Haha – thanks bcworkz. As long as Im doing it “technically wrong” and not just “wrong” Im happy with that. πŸ™‚

    Thread Starter dllive

    (@dllive)

    Thanks guys.

    I think Ill go down the dedicated processing script route. Ive made a start on this and found that if I include wp_load.php in the head of my code I have access to all the WP functions. (this is really useful!).

    Ive also got some session code in place so that – if the user isnt logged in – they are booted out – so hopefully that will stop any spam bots attacking the forms.

    Ive just run into another problem – which is related but slightly different: Within my WordPress template I need to access my own database. Very simple, I just need to pull out all the fields in a row where the id of the row equals the page id. How would I do this?

    Many thanks for your assistance! πŸ™‚

Viewing 9 replies - 31 through 39 (of 39 total)