.gitkeep
3 years ago
route-helper.php
3 years ago
state-helpers.php
2 years ago
template-helpers.php
3 years ago
state-helpers.php
33 lines
| 1 | <?php |
| 2 | if ( ! function_exists( 'sc_initial_state' ) ) { |
| 3 | /** |
| 4 | * Merge data with the existing store. |
| 5 | * |
| 6 | * @param array $data Data that will be merged with the existing store. |
| 7 | * |
| 8 | * @return $data The current store data. |
| 9 | */ |
| 10 | function sc_initial_state( $data = null ) { |
| 11 | if ( $data ) { |
| 12 | \SureCart::state()->mergeData( $data ); |
| 13 | } |
| 14 | return \SureCart::state()->getData(); |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | if ( ! function_exists( 'sc_initial_line_items' ) ) { |
| 19 | /** |
| 20 | * Get the current store state. |
| 21 | * |
| 22 | * @param array $data Data that will be merged with the existing store. |
| 23 | * |
| 24 | * @return array The current store state. |
| 25 | */ |
| 26 | function sc_initial_line_items( $data = [] ) { |
| 27 | if ( $data ) { |
| 28 | return \SureCart::state()->lineItems()->merge( $data ); |
| 29 | } |
| 30 | return \SureCart::state()->lineItems()->get(); |
| 31 | } |
| 32 | } |
| 33 |