Programming (Actions and Filters)

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:

woocommerce-order-proposal.php
do_action( 'wc_order_proposal_remove_old_proposal', $order); This action is called just before an order is moved to the status cancelled because it expired

 

includes / class-wc-order-proposal-ajax.php
do_action( 'wc_order_proposal_meta_box_save_ajax', $post_id); After the data was saved from the order proposal meta box via the “Safe proposal” button on the order backend page

 

includes / class-wc-order-proposal-order.php
do_action( 'wc_order_proposal_meta_box_end', $post_id); Between the order proposal meta box input fields and the “Safe proposal” button on the order backend page
do_action( 'wc_order_proposal_save_meta_box', $post_id, $post ); After the data was saved from the general “Save Order” button on the order backend page

 

templates / emails / customer-order-proposal.php
do_action( 'woocommerce_email_header', $email_heading, $email ); Output the email header
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email ); Order details
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email ); Order meta data
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); Customer details
do_action( 'woocommerce_email_footer', $email ); Email footer

 

templates / pdf / proposal.php
do_action( 'wpo_wcpdf_after_document_label', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); After document label
do_action( 'wpo_wcpdf_before_order_data', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); Before order data
do_action( 'wpo_wcpdf_after_order_data', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); After order data
do_action( 'wpo_wcpdf_before_order_details', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); Before order details
do_action( 'wpo_wcpdf_before_item_meta', $wpo_wcpdf->export->template_type, $item, $wpo_wcpdf->export->order ); Before item meta
do_action( 'wpo_wcpdf_after_item_meta', $wpo_wcpdf->export->template_type, $item, $wpo_wcpdf->export->order ); After item meta
do_action( 'wpo_wcpdf_notes_order_details', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); Notes order details
do_action('woocommerce_pdf_payment_instructions', WCOO_Order::get_id($wpo_wcpdf->export->order)); PDF payment instructions
do_action( 'wpo_wcpdf_after_order_details', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); After order details

 

templates / pdf / order-confirmation.php
do_action( 'wpo_wcpdf_after_document_label', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); After document label
do_action( 'wpo_wcpdf_before_order_data', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); Before order data
do_action( 'wpo_wcpdf_after_order_data', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); After order data
do_action( 'wpo_wcpdf_before_order_details', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); Before order details
do_action( 'wpo_wcpdf_before_item_meta', $wpo_wcpdf->export->template_type, $item, $wpo_wcpdf->export->order ); Before item meta
do_action( 'wpo_wcpdf_after_item_meta', $wpo_wcpdf->export->template_type, $item, $wpo_wcpdf->export->order ); After item meta
do_action( 'wpo_wcpdf_after_order_details', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); After order details

 

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' ) );

}
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' );

}
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;
}