currency-switcher
4 weeks ago
multi-currency
4 weeks ago
setup
4 weeks ago
status
4 weeks ago
store-urls
4 weeks ago
class-wcml-currencies-dropdown-ui.php
5 years ago
class-wcml-custom-files-ui.php
4 weeks ago
class-wcml-languages-upgrade-notice.php
4 years ago
class-wcml-menus-wrap-base.php
4 weeks ago
class-wcml-menus-wrap.php
4 weeks ago
class-wcml-multilingual-ui.php
9 months ago
class-wcml-not-translatable-attributes.php
4 weeks ago
class-wcml-pointer-ui.php
1 year ago
class-wcml-removed-cart-items-ui.php
4 weeks ago
class-wcml-settings-ui.php
4 weeks ago
class-wcml-st-taxonomy-ui.php
11 months ago
class-wcml-sync-taxonomy.php
4 weeks ago
class-wcml-templates-factory.php
4 weeks ago
class-wcml-troubleshooting-ui.php
4 weeks ago
class-wcml-removed-cart-items-ui.php
77 lines
| 1 | <?php |
| 2 | |
| 3 | class WCML_Removed_Cart_Items_UI extends WCML_Templates_Factory { |
| 4 | |
| 5 | private $woocommerce_wpml; |
| 6 | private $sitepress; |
| 7 | private $woocommerce; |
| 8 | |
| 9 | public function __construct( $woocommerce_wpml, $sitepress, $woocommerce ) { |
| 10 | |
| 11 | $this->woocommerce_wpml = $woocommerce_wpml; |
| 12 | $this->sitepress = $sitepress; |
| 13 | $this->woocommerce = $woocommerce; |
| 14 | |
| 15 | parent::__construct(); |
| 16 | } |
| 17 | |
| 18 | public function get_model(){ |
| 19 | |
| 20 | $language_details = $this->sitepress->get_language_details( $this->sitepress->get_current_language() ); |
| 21 | $switched_to = $this->woocommerce->session->get( 'wcml_switched_type' ) === 'currency' ? $this->woocommerce_wpml->multi_currency->get_client_currency() : $language_details[ 'display_name' ]; |
| 22 | |
| 23 | $model = [ |
| 24 | 'products' => $this->get_removed_products(), |
| 25 | 'title' => sprintf( |
| 26 | /* translators: %s is a currency or language name */ |
| 27 | __( 'Products removed after switching to %s:', 'woocommerce-multilingual'), |
| 28 | $switched_to |
| 29 | ), |
| 30 | 'clear' => __( 'Clear list', 'woocommerce-multilingual'), |
| 31 | 'nonce' => wp_create_nonce( 'wcml_clear_removed_items' ), |
| 32 | ]; |
| 33 | |
| 34 | return $model; |
| 35 | } |
| 36 | |
| 37 | public function get_removed_products(){ |
| 38 | |
| 39 | $current_language = $this->sitepress->get_current_language(); |
| 40 | $removed_products_from_session = maybe_unserialize( $this->woocommerce->session->get( 'wcml_removed_items' ) ); |
| 41 | $removed_products = []; |
| 42 | $removed_product_ids = []; |
| 43 | |
| 44 | if( is_array( $removed_products_from_session ) ){ |
| 45 | foreach( $removed_products_from_session as $key => $product_id ){ |
| 46 | $tr_product_id = apply_filters( 'wpml_object_id', $product_id, 'product', false, $current_language ); |
| 47 | |
| 48 | if( !is_null( $tr_product_id ) && !in_array( $tr_product_id, $removed_product_ids ) ){ |
| 49 | $removed_products[ $key ][ 'id' ] = $removed_product_ids[] = $tr_product_id; |
| 50 | $removed_products[ $key ][ 'url' ] = get_post_permalink( $tr_product_id ); |
| 51 | $removed_products[ $key ][ 'title' ] = get_post( $tr_product_id )->post_title; |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | return $removed_products; |
| 57 | |
| 58 | } |
| 59 | |
| 60 | public function render(){ |
| 61 | echo $this->get_view(); |
| 62 | } |
| 63 | |
| 64 | protected function init_template_base_dir() { |
| 65 | $this->template_paths = [ |
| 66 | WCML_PLUGIN_PATH . '/templates/', |
| 67 | ]; |
| 68 | } |
| 69 | |
| 70 | public function get_template() { |
| 71 | return 'removed-cart-items.twig'; |
| 72 | } |
| 73 | |
| 74 | |
| 75 | |
| 76 | } |
| 77 |