Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function process_cart() {
- foreach ( WC()->cart->get_cart() as $cart_item ) {
- do_action( 'woocommerce/cart_loop/start', $cart_item );
- if ( $cart_item['quantity'] ) {
- if ( $cart_item['variation_id'] ) {
- $product = wc_get_product( $cart_item['variation_id'] );
- } else {
- $product = wc_get_product( $cart_item['product_id'] );
- }
- $this->total_amount = self::format_number( $cart_item['line_total'] );
- $this->subtotal_amount = self::format_number( $cart_item['line_subtotal'] );
- $this->total_tax_amount = self::format_number( array_sum( $cart_item['line_tax_data']['total'] ) );
- $this->subtotal_tax_amount = self::format_number( array_sum( $cart_item['line_tax_data']['subtotal'] ) );
- $this->quantity = $cart_item['quantity'];
- $klarna_item = array(
- 'reference' => $this->get_item_reference( $product ),
- 'name' => $this->get_item_name( $cart_item ),
- 'quantity' => $this->get_item_quantity( $cart_item ),
- 'unit_price' => $this->get_item_price( $cart_item ),
- 'tax_rate' => $this->get_item_tax_rate( $cart_item, $product ),
- 'total_amount' => $this->get_item_total_amount( $cart_item, $product ),
- 'total_tax_amount' => $this->get_item_tax_amount( $cart_item, $product ),
- 'total_discount_amount' => $this->get_item_discount_amount( $cart_item, $product ),
- );
- if ( class_exists( 'WC_Subscriptions_Product' ) && WC_Subscriptions_Product::is_subscription( $product ) ) {
- $klarna_item['subscription'] = array(
- 'name' => $klarna_item['name'],
- 'interval' => strtoupper( WC_Subscriptions_Product::get_period( $product ) ),
- 'interval_count' => absint( WC_Subscriptions_Product::get_interval( $product ) ),
- );
- }
- // Product type.
- if ( $product->is_downloadable() || $product->is_virtual() ) {
- $klarna_item['type'] = 'digital';
- } else {
- $klarna_item['type'] = 'physical';
- }
- // Add images.
- $klarna_checkout_settings = get_option( 'woocommerce_kco_settings', array() );
- if ( isset( $klarna_checkout_settings ) && 'yes' === $klarna_checkout_settings['send_product_urls'] ) {
- $klarna_item['product_url'] = $this->get_item_product_url( $product );
- if ( $this->get_item_image_url( $product ) ) {
- $klarna_item['image_url'] = $this->get_item_image_url( $product );
- }
- }
- /* This should better support get_catalog_visibility = hidden on product components. */
- $cart_line_item = apply_filters( 'kco_wc_cart_line_item', $klarna_item, $cart_item );
- if ( $cart_line_item ) {
- $this->order_lines[] = $cart_line_item;
- }
- }
- do_action( 'woocommerce/cart_loop/end', $cart_item );
- }
- }
Advertisement
Comments
-
- /wp-content/plugins/klarna-checkout-for-woocommerce/classes/requests/helpers/class-kco-request-cart.php
-
Comment was deleted
Add Comment
Please, Sign In to add comment
Advertisement