Table of Contents
This plugin gives you the possibility to customize and modify different parts of the the programming code. Similar to other plugins, we use actions and filters for this:
Action hooks #
woocommerce-order-proposal.php
/** * This action is called just before an order is moved * to the status cancelled because it expired */ do_action( 'wc_order_proposal_remove_old_proposal', $order);
includes/class-wc-order-proposal-ajax.php
/** * After the data was saved from the order proposal meta box * via the “Safe proposal” button on the order backend page */ do_action( 'wc_order_proposal_meta_box_save_ajax', $post_id);
includes/class-wc-order-proposal-order.php
/** * Between the order proposal meta box input fields and * the “Safe proposal” button on the order backend page */ do_action( 'wc_order_proposal_meta_box_end', $post_id); /** * After the data was saved from the general “Save Order” * button on the order backend page */ do_action( 'wc_order_proposal_save_meta_box', $post_id, $post );
templates/emails/customer-order-proposal.php
// Output the email header do_action( 'woocommerce_email_header', $email_heading, $email ); // Order details do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email ); // Order meta data do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email ); // Customer details do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); // Email footer do_action( 'woocommerce_email_footer', $email );
templates/pdf/proposal.php
// After document label do_action( 'wpo_wcpdf_after_document_label', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); // Before order data do_action( 'wpo_wcpdf_before_order_data', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); // After order data do_action( 'wpo_wcpdf_after_order_data', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); // Before order details do_action( 'wpo_wcpdf_before_order_details', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); // Before item meta do_action( 'wpo_wcpdf_before_item_meta', $wpo_wcpdf->export->template_type, $item, $wpo_wcpdf->export->order ); // After item meta do_action( 'wpo_wcpdf_after_item_meta', $wpo_wcpdf->export->template_type, $item, $wpo_wcpdf->export->order ); // Notes order details do_action( 'wpo_wcpdf_notes_order_details', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); // PDF payment instructions do_action('woocommerce_pdf_payment_instructions', WCOO_Order::get_id($wpo_wcpdf->export->order)); // After order details do_action( 'wpo_wcpdf_after_order_details', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order );
templates/pdf/order-confirmation.php
// After document label do_action( 'wpo_wcpdf_after_document_label', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); // Before order data do_action( 'wpo_wcpdf_before_order_data', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); // After order data do_action( 'wpo_wcpdf_after_order_data', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); // Before order details do_action( 'wpo_wcpdf_before_order_details', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); // Before item meta do_action( 'wpo_wcpdf_before_item_meta', $wpo_wcpdf->export->template_type, $item, $wpo_wcpdf->export->order ); // After item meta do_action( 'wpo_wcpdf_after_item_meta', $wpo_wcpdf->export->template_type, $item, $wpo_wcpdf->export->order ); // After order details do_action( 'wpo_wcpdf_after_order_details', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order );
Code snippet examples #
Automatically move from Order Proposal Requested to Order Proposal #
add_action( ' woocommerce_order_status_order-proposalreq', 'wc_order_proposal_change_proposalreq' ); function wc_order_proposal_change_proposalreq($order_id) { $order = wc_get_order($order_id); // Set order status to order-proposal $order->update_status( 'wc-order-proposal', __( 'Order Proposal', 'woocommerce' ) ); }
Move Order Proposal from Pending to a custom status #
add_action( ' woocommerce_order_status_order-proposal_to_pending', 'wc_order_proposal_change_proposal_to_pending' ); function wc_order_proposal_change_proposal_to_pending($order_id) { $order = wc_get_order($order_id); // Set order status to custom $order->update_status( 'NEWSTATUS', 'MSG' ); }
Rename Proposal to Quote #
add_filter('gettext_with_context', 'change_proposal_to_quote_context', 10, 4 ); function change_proposal_to_quote_context( $translation, $text, $context, $domain ) { if ( $domain === 'woocommerce-order-proposal' ) { $translation = str_ireplace('Proposal', 'Quotation', $translation); } return $translation; } add_filter('gettext', 'change_proposal_to_quote', 10, 3 ); function change_proposal_to_quote( $translation, $text, $domain ) { if ( $domain === 'woocommerce-order-proposal' ) { $translation = str_ireplace('Proposal', 'Quotation', $translation); } return $translation; }