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

Use a line item to add shipping #34

Merged
merged 2 commits into from
Feb 3, 2021

Conversation

agileware-fj
Copy link
Contributor

This builds on #33 and inserts the shipping cost into the CiviCRM Contribution as a line item, meaning it can be synchronised to external accounting packages and shipping costs can be summarised more easlier.

@monishdeb
Copy link
Contributor

Its a useful feature to record the shipping cost in a separate line-item. Here's the resulting line-item records for a $20 purchase that includes $2 as a shipping charge:

{

    "is_error": 0,
    "version": 3,
    "count": 2,
    "values": [
        {
            "id": "122671",
            "entity_table": "civicrm_contribution",
            "entity_id": "25964",
            "contribution_id": "25964",
            "price_field_id": "1",
            "label": "Shipping",
            "qty": "1.00",
            "unit_price": "20.00",
            "line_total": "20.00",
            "financial_type_id": "8",
            "non_deductible_amount": "0.00",
            "tax_amount": "0.00",
            "contribution_type_id": "8",
            "api.FinancialItem.get": {
                "is_error": 0,
                "version": 3,
                "count": 1,
                "id": 48878,
                "values": [
                    {
                        "id": "48878",
                        "created_date": "2021-01-20 04:29:45",
                        "transaction_date": "2021-01-20 04:29:45",
                        "contact_id": "49916",
                        "description": "Shipping",
                        "amount": "2.00",
                        "currency": "CAD",
                        "financial_account_id": "18",
                        "status_id": "1",
                        "entity_table": "civicrm_line_item",
                        "entity_id": "122671"
                    }
                ]
            }
        },
        {
            "id": "122672",
            "entity_table": "civicrm_contribution",
            "entity_id": "25964",
            "contribution_id": "25964",
            "price_field_id": "1",
            "label": "PEI T-Shirt",
            "qty": "1.00",
            "unit_price": "20.00",
            "line_total": "20.00",
            "financial_type_id": "60",
            "non_deductible_amount": "0.00",
            "tax_amount": "0.00",
            "contribution_type_id": "60",
            "api.FinancialItem.get": {
                "is_error": 0,
                "version": 3,
                "count": 1,
                "id": 48879,
                "values": [
                    {
                        "id": "48879",
                        "created_date": "2021-01-20 04:29:45",
                        "transaction_date": "2021-01-20 04:29:45",
                        "contact_id": "49916",
                        "description": "PEI T-Shirt",
                        "amount": "18.00",
                        "currency": "CAD",
                        "financial_account_id": "90",
                        "status_id": "1",
                        "entity_table": "civicrm_line_item",
                        "entity_id": "122672"
                    }
                ]
            }
        }
    ]
}

I have reviewed the patch and have a doubt that why we are using hard-coded financial type id -8 for recording line-item for sipping charges instead of the default_financial_type. I think it would be appropriate if we allow user to choose Financial type for shipping item in WooCommerce-CiviCRM setting page.

'line_total' => $shipping_cost,
'unit_price' => $shipping_cost,
'label' => "Shipping",
'financial_type_id' => 8,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we replace it with default_financial_type or a chosen financial type for recording shipping item from setting page?

Copy link

@agileware-justin agileware-justin Jan 21, 2021

Choose a reason for hiding this comment

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

My thoughts here are that the plugin should create a new "Shipping" Financial Type in CiviCRM when enabled, if it does not already exist. And then use this "Shipping" Financial Type.

This saves having to provide yet another setting page to update and will work without any user intervention after installation.

Copy link
Owner

Choose a reason for hiding this comment

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

@agileware-justin the plugin does have a settings page to map Financial types, enable address sync, etc. and also a setting on the Product itself, I think it does make sense to have those configurable, WooCommerce has variable shipping rates, and there's also downloadable Products (i.e. no shipping).

Choose a reason for hiding this comment

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

@mecachisenros nice to hear from you. Cool, agree makes sense to use the existing settings (even though it's yet another settings page YASP!).

@mecachisenros mecachisenros merged commit e6c559c into mecachisenros:master Feb 3, 2021
@mecachisenros
Copy link
Owner

@monishdeb @agileware-fj @agileware-justin
Merged with some changes:

  • shipping financial type configurable in the settings tab

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.

5 participants