-
Notifications
You must be signed in to change notification settings - Fork 91
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
gwaft-template-collapsible.php
: Added Order Summary as an additional last page.
#1052
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,18 @@ | |
$pages = $data['form']['pagination']['pages']; | ||
$page_groups = array(); | ||
foreach ( $data['items'] as $item ) { | ||
$field = $item['field']; | ||
$field = rgar( $item, 'field' ); | ||
|
||
// Add Order Summary as a separate last page. | ||
if ( ! $field && rgar( $item, 'label' ) == apply_filters( 'gwaft_order_summary_label', 'Order Summary' ) ) { | ||
// Storing order summary page as '-1' to be the last page, and avoid conflicts with the actual page numbers. | ||
$page_groups[-1][] = $item; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain how the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was storing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it! Would it work to push the order summary item to the end of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was vary of other potential customizations that may be thrown it by customers, adding additional pages and stuff? Thought to keep it 'separate' from the rest of the stuff. Unless if you suggest that pushing it at the end is a safer way to go forth, I will make the update. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do think throwing it on the end is a safer bet, but that said, I'm actually not super familiar with other potential customizations etc. I'll leave the final call to you! If you do go with |
||
$pages[-1] = apply_filters( 'gwaft_order_summary_label', 'Order Summary' ); | ||
continue; | ||
} | ||
|
||
// Skip hidden fields. | ||
if ( $field->type === 'hidden' || $field->visibility === 'hidden' ) { | ||
if ( ! $field || $field->type === 'hidden' || $field->visibility === 'hidden' ) { | ||
continue; | ||
} | ||
// Adjust pageNumber to be zero-based. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check on the
label
value feels potentially flimsy to meThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how the

order summary
item is:For regular fields, it is:

So an alternate logic could possibly be "if ( ! field )". But, that could possibly be a false flag is what I wondered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following is a note for myself:
Looking at the code in gw-all-fields-template.php, it looks like
$field
will always be present unless it's the product summary.The product summary is added here and the other two instances (where
$field
is included) are here and hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's tricky.
A second option, is to modify the
gw-all-fields-template
snippet so that the order summary item has an additional key / flag that could be checked here. (Maybeis_order_summary => true
?).Given this is a snippet, I'm okay leaving this as is.
@saifsultanc can you add a comment explaining the conditional / how it's expected to work?