renderStatus = () => { const { order } = this.props; return isOrderWaitingPayment( order.status ) ? <OrderStatusSelect value={ this.state.status } onChange={ this.updateStatus } /> : <OrderStatus status={ order.status } showShipping={ false } />; }
renderViewButtons = () => { const { isInvoiceSending, order, translate } = this.props; const buttons = [ <Button key="edit" primary onClick={ this.toggleEditing }> { translate( 'Edit Order' ) } </Button>, ]; if ( isOrderWaitingPayment( order.status ) ) { buttons.unshift( <Button key="resend-invoice" onClick={ this.triggerInvoice } busy={ isInvoiceSending } disabled={ isInvoiceSending } > { translate( 'Resend Invoice' ) } </Button> ); } // Unshifting so that the Delete is the first action in the row buttons.unshift( <Button key="delete" borderless scary onClick={ this.deleteOrder }> <Gridicon icon="trash" /> { translate( 'Delete' ) } </Button> ); return buttons; };
getPaymentAction = () => { const { order, translate } = this.props; const codProcessing = 'cod' === order.payment_method && 'processing' === order.status; if ( 'refunded' === order.status || codProcessing ) { return null; } else if ( isOrderWaitingPayment( order.status ) ) { return <Button onClick={ this.markAsPaid }>{ translate( 'Mark as Paid' ) }</Button>; } return <Button onClick={ this.toggleDialog }>{ translate( 'Submit Refund' ) }</Button>; };
saveOrder = () => { const { siteId, order, translate } = this.props; const successOpts = { duration: 8000 }; if ( isOrderWaitingPayment( order.status ) ) { successOpts.button = translate( 'Send new invoice to customer' ); successOpts.onClick = this.triggerInvoice; } const onSuccess = dispatch => { dispatch( successNotice( translate( 'Order successfully updated.' ), successOpts ) ); }; const onFailure = dispatch => { dispatch( errorNotice( translate( 'Unable to save order.' ), { duration: 8000 } ) ); }; recordTrack( 'calypso_woocommerce_order_edit_save' ); this.props.saveOrder( siteId, order, onSuccess, onFailure ); };
const onSuccess = ( dispatch, orderId ) => { const successOpts = { duration: 8000, displayOnNextPage: true, }; dispatch( successNotice( translate( 'Order successfully created. {{ordersLink}}View all orders{{/ordersLink}}.', { components: { ordersLink: <a href={ getLink( '/store/orders/:site/', site ) } />, }, } ), successOpts ) ); // Send invoice if the order is awaiting payment and there is an email if ( isOrderWaitingPayment( order.status ) && get( order, 'billing.email', false ) ) { this.triggerInvoice( siteId, orderId ); } page.redirect( getLink( `/store/order/:site/${ orderId }`, site ) ); };