Skip to content
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

Feature/Product type #7

Merged
merged 8 commits into from
Mar 20, 2019
Merged

Feature/Product type #7

merged 8 commits into from
Mar 20, 2019

Conversation

kidunot89
Copy link
Member

@kidunot89 kidunot89 commented Mar 17, 2019

Your checklist for this pull request

Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

🚨Please review the guidelines for contributing to this repository.

  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Make sure you are requesting to pull request from a topic/feature/bugfix branch (right side). Don't pull request from your master!

What does this implement/fix? Explain your changes.

Tests

  • ProductQueriesTest

Enum Types

  • BackorderEnum
  • CatalogVisibilityEnum
  • DiscountType
  • StockStatus
  • TaxStatus

Object Types

  • Product
  • ProductAttribute

Connections

  • Coupon<->Products - products, excludedProducts
  • Coupon<->ProductCategories - productCategories, excludedProductCategories
  • Product<-> Products - upsell, crossSell, variations
  • Product<->ProductCategories - categories
  • Product<->ProductTags - tags
  • Product<->ProductAttribute - attributes, defaultAttributes
  • Product<->MediaItem - galleryImages

Query example

query {
    product(id: \"{$product->get_id()}\") {
        productId
        name
        slug
        date
        modified
        status
        featured
        catalogVisibility
        description
        shortDescription
        sku
        price
        regularPrice
        salePrice
        dateOnSaleFrom
        dateOnSaleTo
        totalSales
        taxStatus
        taxClass
        manageStock
        stockQuantity
        stockStatus
        backorders
        soldIndividually
        weight
        length
        width
        height
        reviewsAllowed
        purchaseNote
        menuOrder
        virtual
        downloadable
        shippingClassId
        downloads
        downloadLimit
        downloadExpiry
        ratingCount
        averageRating
        reviewCount
        upsell {
            nodes {
                ...Product fields
            }
        }
        crossSell {
            nodes {
                ...Product fields
            }
        }
        parent {
            ...Product fields
        }
        categories {
            nodes {
                ...Taxonomy fields
            }
        }
        tags {
            nodes {
                ...Taxonomy fields
            }
        }
        image {
            ...MediaItem fields
        }
        galleryImages {
            nodes {
                ...MediaItem fields

            }
        }
        attributes {
            nodes {
               id
               name
               position
               visible
               variation
               options
            }
        }
        defaultAttributes {
            nodes {
               id
               name
            }
        }
    }
}

Does this close any currently open issues?

Any relevant logs, error output, GraphiQL screenshots, etc?

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Any other comments?

Where has this been tested?

Operating System: Ubuntu 18.04

WordPress Version: 5.1

@kidunot89 kidunot89 self-assigned this Mar 17, 2019
Copy link
Contributor

@renatonascalves renatonascalves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions! Looking good! :)

* @access public
*/
public static function resolve_product( $id ) {
$product = new \WC_Product( $id );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kidunot89 Is the idea to create a product implementation for each type of products? WC_Product_Simple, WC_Product_Variation, etc?

If yes, can we do something to verify the WC_Product and classes that extend WC_Abstract_Legacy_Product?

That would allow WC_Product_Subscription_Variation, WC_Product_Subscription, and other product types to work without having to create their own product implementation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolve_product is only used in the root queries product and productBy, however I will add the ability to filter the resolver of the Product type, if this does not work for other Woo extensions

}
if ( 'product_variation' === $query->query['post_type'] ) {
foreach ( $query_info['items'] as &$item ) {
$item = new \WC_Product_Variation( $item->ID );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be WC_Product_Simple and others here as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm waiting for the Model Layer PR to be completed before optimizing base on queried fields. That way optimization can be done in Product model and I can avoid having to refactor.

@kidunot89 kidunot89 merged commit 9d08832 into develop Mar 20, 2019
@renatonascalves renatonascalves deleted the feature/product-type branch May 4, 2019 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants