Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Search by order number for return transactions. #43

Open
wants to merge 7 commits into
base: 7.x-2.x
Choose a base branch
from

Conversation

shabananavas
Copy link

Copy link

@wilderuncat wilderuncat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall, just a few questions.

'#default_value' => !empty($form_state['values']['order_search']['input']) ? $form_state['values']['order_search']['input'] : NULL,
);

$form['order_search']['search'] = array(
'#type' => 'button',
'#value' => t('Go'),
'#value' => t('Return items from this order'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a little long to me... Maybe something like "Lookup Order" would be more succinct?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This title was suggested by @travis-bradbury , to make it clear to the user. So might need to get a consensus on this one.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll yield to travis, he is a better authority here than me.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not saying "Return items from this order" is the best. It is a little long. I just wanted something that describes what the user is trying to do.

@@ -936,3 +937,80 @@ function _commerce_pos_override_confirm_validate($form, &$form_state) {
// Add the product to the overridden items list.
$form_state['out_of_stock_overridden_products'][$form_state['triggering_element']['#product_id']] = $form_state['triggering_element']['#product_id'];
}

/**
* Returns a modal form displaying each item in an order along with a checkbox

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docblock should have a one-line summary under 80 characters long. Then a longer description underneath. Also, it would be useful to include the $order as a @param

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will do.

function commerce_pos_return_select_item_popup(&$form, &$form_state, $order) {

// Load our generic modal form.
$form['commerce_pos_return_select_item_modal'] = commerce_pos_form_modal(array(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you also need to do

form_load_include($form_state, 'inc', 'commerce_pos', 'includes/commerce_pos.common');

before this to make sure it is included?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, we don't need it. It works right out of the box :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit curious why it works though... Maybe another form in the same request is including it. But what if this form is called alone? Would it still work? Would it hurt to include it twice? Might be better to be explicit. But I haven't tested it so not sure.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I didn't give too much thought into it. Travis would be able to answer this quickly as he did the restructuring for the generic modal.

// Go through each item in the order and generate the html for the items
// display.
foreach (entity_metadata_wrapper('commerce_order', $order)->commerce_line_items as $delta => $line_item_wrapper) {
if (in_array($line_item_wrapper->type->value(), commerce_product_line_item_types())) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found it best to first check if $line_item_wrapper->type exists before checking the value. I've seen many orders / line items get corrupted and things like this result in a 500 error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

* This popup shows a checkbox next to each item for the user to add that item
* to the return transaction.
*
* @param $order
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing parameter type.

@param object $order

That should get travis to start passing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants