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
Add purchase task to experimental task lists #33178
Changes from 5 commits
d6efa29
702e137
76301fe
485c5a0
4044869
3536856
eb449ed
02d9f91
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { Button } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import TimerImage from './timer.svg'; | ||
import { WC_ASSET_URL } from '../../utils/admin-settings'; | ||
|
||
const PurchaseHeader = ( { task, goToTask } ) => { | ||
return ( | ||
<div className="woocommerce-task-header__contents-container"> | ||
<img | ||
alt={ __( 'Purchase illustration', 'woocommerce' ) } | ||
src={ | ||
WC_ASSET_URL + 'images/task_list/purchase-illustration.png' | ||
} | ||
className="svg-background" | ||
/> | ||
<div className="woocommerce-task-header__contents"> | ||
<h1>{ task.title }</h1> | ||
<p> | ||
{ __( | ||
'Good choice! You chose to add amazing new features to your store. Continue to checkout to complete your purchase.', | ||
'woocommerce' | ||
) } | ||
</p> | ||
<Button | ||
isSecondary={ task.isComplete } | ||
isPrimary={ ! task.isComplete } | ||
onClick={ goToTask } | ||
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. See the custom purchase task item we have here: https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce-admin/client/tasks/fills/purchase.js I know for other headers like WooCommerce Payments we copied that custom logic to the header also instead of using |
||
> | ||
{ __( 'Continue', 'woocommerce' ) } | ||
</Button> | ||
<p className="woocommerce-task-header__timer"> | ||
<img src={ TimerImage } alt="Timer" />{ ' ' } | ||
<span>{ task.time }</span> | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PurchaseHeader; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,7 +151,6 @@ | |
|
||
.svg-background { | ||
right: 6%; | ||
width: 25%; | ||
} | ||
} | ||
|
||
|
@@ -241,6 +240,11 @@ | |
flex: 1; | ||
overflow: hidden; | ||
width: 100%; | ||
|
||
img { | ||
max-height: 150px; | ||
width: auto; | ||
} | ||
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. 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. Add max width and max height. Seems to be working well on my end, can you double check on yours? 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. Looks good on my end now to :) |
||
} | ||
|
||
.svg-background { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: add | ||
|
||
Add purchase task to experimental task lists #33178 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,20 +54,52 @@ public function get_id() { | |
* @return string | ||
*/ | ||
public function get_title() { | ||
$products = $this->get_paid_products_and_themes(); | ||
$products = $this->get_paid_products_and_themes(); | ||
$first_product = count( $products['remaining'] ) >= 1 ? $products['remaining'][0] : false; | ||
$additional_count = count( $products['remaining'] ) - 1; | ||
|
||
if ( $this->get_parent_option( 'use_completed_title' ) && $this->is_complete() ) { | ||
return count( $products['remaining'] ) === 1 | ||
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. 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. Same probably goes for $addtional_count and line 79. 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. Ya, good point. This doesn't work well as you complete purchases. Updated. |
||
? sprintf( | ||
/* translators: %1$s: a purchased product name */ | ||
__( | ||
'You added %1$s', | ||
'woocommerce' | ||
), | ||
$first_product | ||
) | ||
: sprintf( | ||
/* translators: %1$s: a purchased product name, %2$d the number of other products purchased */ | ||
_n( | ||
'You added %1$s and %2$d other product', | ||
'You added %1$s and %2$d other products', | ||
$additional_count, | ||
'woocommerce' | ||
), | ||
$products['remaining'][0], | ||
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. Also in the $products['purchaseable'] the items are array's of plugins, so this will probably be |
||
$additional_count | ||
); | ||
} | ||
|
||
return count( $products['remaining'] ) === 1 | ||
? sprintf( | ||
/* translators: %1$s: list of product names comma separated, %2%s the last product name */ | ||
/* translators: %1$s: a purchaseable product name */ | ||
__( | ||
'Add %s to my store', | ||
'woocommerce' | ||
), | ||
$products['remaining'][0] | ||
) | ||
: __( | ||
'Add paid extensions to my store', | ||
'woocommerce' | ||
: sprintf( | ||
/* translators: %1$s: a purchaseable product name, %2$d the number of other products to purchase */ | ||
_n( | ||
'Add %1$s and %2$d more product to my store', | ||
'Add %1$s and %2$d more products to my store', | ||
$additional_count, | ||
'woocommerce' | ||
), | ||
$products['remaining'][0], | ||
$additional_count | ||
); | ||
} | ||
|
||
|
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 should actually do something different, as it navigates to the
purchase
task screen which doesn't exist.It should show a popup like this instead:
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.
👍 I think ultimately if we keep this variant of the task list we should strive to dry up these headers and actions a bit. There is a lot of duplication between components and even backend data being replicated on the frontend that is going to cause headaches down the road.