Skip to content

Commit 015fbdb

Browse files
committed
Fix #87
1 parent 46c6531 commit 015fbdb

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

woocommerce-delivery-notes/includes/wcdn-all-component.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,24 +209,24 @@ function example_removed_payment_method( $fields ) {
209209
),
210210
6 => array (
211211
'question' => 'How can I add some more fields to the order info section? ',
212-
'answer' => 'Use the `wcdn_order_info_fields` filter hook. It returns all the fields as array. Read the WooCommerce documentation to learn how you get custom checkout and order fields. Tip: To get custom meta field values you will most probably need the `get_post_meta( $order->id, \'your_meta_field_name\', true);` function and of course the `your_meta_field_name`.
212+
'answer' => 'Use the `wcdn_order_info_fields` filter hook. It returns all the fields as array. Read the WooCommerce documentation to learn how you get custom checkout and order fields. Tip: To get custom meta field values you will most probably need the `get_post_meta( $order->get_id(), \'your_meta_field_name\', true);` function and of course the `your_meta_field_name`.
213213
<br/><br/>
214214
An example that adds a \'VAT\' and \'Customer Number\' field to the end of the list. Paste the code in the `functions.php` file of your theme:
215215
<pre>
216216
function example_custom_order_fields( $fields, $order ) {
217217
$new_fields = array();
218218
219-
if( get_post_meta( $order->id, \'your_meta_field_name\', true ) ) {
219+
if( get_post_meta( $order->get_id(), \'your_meta_field_name\', true ) ) {
220220
$new_fields[\'your_meta_field_name\'] = array(
221221
\'label\' => \'VAT\',
222-
\'value\' => get_post_meta( $order->id, \'your_meta_field_name\', true )
222+
\'value\' => get_post_meta( $order->get_id(), \'your_meta_field_name\', true )
223223
);
224224
}
225225
226-
if( get_post_meta( $order->id, \'your_meta_field_name\', true ) ) {
226+
if( get_post_meta( $order->get_id(), \'your_meta_field_name\', true ) ) {
227227
$new_fields[\'your_meta_field_name\'] = array(
228228
\'label\' => \'Customer Number\',
229-
\'value\' => get_post_meta( $order->id, \'your_meta_field_name\', true )
229+
\'value\' => get_post_meta( $order->get_id(), \'your_meta_field_name\', true )
230230
);
231231
}
232232
@@ -242,9 +242,9 @@ function example_custom_order_fields( $fields, $order ) {
242242
243243
<pre>
244244
function example_product_image( $product ) {
245-
if( isset( $product->id ) && has_post_thumbnail( $product->id ) ) {
245+
if( ( '' !== $product->get_id() ) && has_post_thumbnail( $product->get_id() ) ) {
246246
echo get_the_post_thumbnail(
247-
$product->id,
247+
$product->get_id(),
248248
array( 40, 40 ),
249249
array( \'loading\' => false )
250250
);

woocommerce-delivery-notes/readme.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,25 +237,25 @@ add_filter( 'wcdn_order_info_fields', 'example_removed_payment_method' );
237237

238238
= How can I add some more fields to the order info section? =
239239

240-
Use the `wcdn_order_info_fields` filter hook. It returns all the fields as array. Read the WooCommerce documentation to learn how you get custom checkout and order fields. Tip: To get custom meta field values you will most probably need the `get_post_meta( $order->id, 'your_meta_field_name', true);` function and of course the `your_meta_field_name`.
240+
Use the `wcdn_order_info_fields` filter hook. It returns all the fields as array. Read the WooCommerce documentation to learn how you get custom checkout and order fields. Tip: To get custom meta field values you will most probably need the `get_post_meta( $order->get_id(), 'your_meta_field_name', true);` function and of course the `your_meta_field_name`.
241241

242242
An example that adds a 'VAT' and 'Customer Number' field to the end of the list. Paste the code in the `functions.php` file of your theme:
243243

244244
`
245245
function example_custom_order_fields( $fields, $order ) {
246246
$new_fields = array();
247247

248-
if( get_post_meta( $order->id, 'your_meta_field_name', true ) ) {
248+
if( get_post_meta( $order->get_id(), 'your_meta_field_name', true ) ) {
249249
$new_fields['your_meta_field_name'] = array(
250250
'label' => 'VAT',
251-
'value' => get_post_meta( $order->id, 'your_meta_field_name', true )
251+
'value' => get_post_meta( $order->get_id(), 'your_meta_field_name', true )
252252
);
253253
}
254254

255-
if( get_post_meta( $order->id, 'your_meta_field_name', true ) ) {
255+
if( get_post_meta( $order->get_id(), 'your_meta_field_name', true ) ) {
256256
$new_fields['your_meta_field_name'] = array(
257257
'label' => 'Customer Number',
258-
'value' => get_post_meta( $order->id, 'your_meta_field_name', true )
258+
'value' => get_post_meta( $order->get_id(), 'your_meta_field_name', true )
259259
);
260260
}
261261

@@ -272,8 +272,8 @@ An example that adds a 40px large product image. Paste the code in the `function
272272

273273
`
274274
function example_product_image( $product ) {
275-
if( isset( $product->id ) && has_post_thumbnail( $product->id ) ) {
276-
echo get_the_post_thumbnail( $product->id, array( 40, 40 ), array( 'loading' => false ) );
275+
if( ( '' !== $product->get_id() ) && has_post_thumbnail( $product->get_id() ) ) {
276+
echo get_the_post_thumbnail( $product->get_id(), array( 40, 40 ), array( 'loading' => false ) );
277277
}
278278
}
279279
add_action( 'wcdn_order_item_before', 'example_product_image' );

0 commit comments

Comments
 (0)