Weak hands cannot be planted, meager skills have no foundation. Shallow wisdom is futile, how can one hope for a good name?扰扰从役倦，屑屑身事微。少壮轻年月，迟暮惜光辉。
<html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><?php

namespace Hostinger\Reach\Dto;

use WC_Product;

class CartItem {

    private WC_Product $product;
    private int $quantity;

    public function __construct( int $product_id, int $quantity ) {
        $this->product  = wc_get_product( $product_id );
        $this->quantity = $quantity;
    }

    public function to_array(): array {
        return array(
            'quantity'    => $this->quantity,
            'product_id'  => $this->product->get_id(),
            'sku'         => $this->product->get_sku(),
            'link'        => $this->product->get_permalink(),
            'name'        => $this->product->get_name(),
            'price'       => $this->product->get_price(),
            'description' => $this->product->get_description(),
            'thumbnail'   => $this->get_product_thumbnail( $this->product ),
            'tags'        => $this->get_product_tags( $this->product ),
            'categories'  => $this->get_categories( $this->product ),
        );
    }

    public function get_categories( object $product ): array {
        $categories   = array();
        $category_ids = $product->get_category_ids();

        if ( empty( $category_ids ) ) {
            return $categories;
        }

        foreach ( $category_ids as $category_id ) {
            $term = get_term( $category_id, 'product_cat' );

            if ( ! $term || is_wp_error( $term ) ) {
                continue;
            }

            $categories[] = array(
                'id'   => $term->term_id,
                'name' => $term->name,
                'slug' => $term->slug,
                'link' => get_term_link( $term ),
            );
        }

        return $categories;
    }

    public function get_product_thumbnail( object $product ): string {
        $image_data = $product->get_image_id() ? wp_get_attachment_image_src( $product->get_image_id(), 'full' ) : array();
        if ( ! empty( $image_data ) ) {
            return $image_data[0];
        }

        return '';
    }

    public funct