WordPress.org

Ready to get started?Download WordPress

Forums

WP eCommerce
Overriding wpsc_cart quantity (2 posts)

  1. ababra
    Member
    Posted 1 year ago #

    All I want to do is update the quantity of items in $wpsc_cart. No matter how many times a user clicks the "Add to cart" button, I want the quantity per item to override to only 1 for each item.

    I figured I could do an array search through $wpsc_cart and just update all instances of "quantity" to 1, however I am having trouble.

    I did a print_r($wpsc_cart) but having trouble doing the quantity update. Any help would be really appreciated!

    Here's the dump of my $wpsc_cart, I just want to update any key named "quantity" and override with a value of 1.

    Object ( [delivery_country] => CA
    [selected_country] => US
    [delivery_region] => 9
    [selected_region] => 9
    [selected_shipping_method] =>
    [selected_shipping_option] =>
    [selected_shipping_amount] =>
    [coupon] =>
    [tax_percentage] => 0
    [unique_id] => df728de019e71fb05e6125760acabf8b336b4e2d
    [errors] => Array ( )
    [total_tax] => 0
    [base_shipping] =>
    [total_item_shipping] =>
    [total_shipping] =>
    [subtotal] => 7200
    [total_price] => 7200
    [uses_shipping] =>
    [is_incomplete] => 1

    [cart_items] => Array (
    [0] => wpsc_cart_item Object (
    [cart] => wpsc_cart Object *RECURSION*
    [product_id] => 436
    [variation_values] =>
    [product_variations] =>
    [variation_data] =>
    [quantity] => 45
    [provided_price] =>
    [product_name] => Candidate Physical Ability Test (CPAT)

    [category_list] => Array ( [0] => product-category ) [category_id_list] => Array ( [0] => 14 ) [unit_price] => 160 [total_price] => 7200 [taxable_price] => 0 [tax] => 0 [weight] => 0 [shipping] => 0 [sku] => [product_url] => http://xxxxxx [image_id] => [thumbnail_image] => [custom_tax_rate] => [meta] => Array ( [0] => Array ( [wpec_taxes_taxable_amount] => [external_link] => [external_link_text] => [external_link_target] => [no_shipping] => 1 [weight] => 0 [weight_unit] => pound [dimensions] => Array ( [height] => 0 [height_unit] => in [width] => 0 [width_unit] => in [length] => 0 [length_unit] => in ) [shipping] => Array ( [local] => 0 [international] => 0 ) [merchant_notes] => [engraved] => 0 [can_have_uploaded_image] => 0 [enable_comments] => [notify_when_none_left] => 0 [unpublish_when_none_left] => 0 [quantity_limited] => 0 [special] => 0 [display_weight_as] => pound [table_rate_price] => Array ( [quantity] => Array ( ) [table_price] => Array ( ) ) [google_prohibited] => 0 ) ) [is_donation] => 0 [apply_tax] => 1 [priceandstock_id] => 0 [custom_message] => [custom_file] => [comment] => [time_requested] => [file_data] => [is_customisable] => [stock] => [uses_shipping] => 0 [has_limited_stock] => [file_id] => [is_downloadable] => ) ) [cart_item] => wpsc_cart_item Object ( [cart] => wpsc_cart Object *RECURSION* [product_id] => 436 [variation_values] => [product_variations] => [variation_data] => [quantity] => 45 [provided_price] => [product_name] => Candidate Physical Ability Test (CPAT) [category_list] => Array ( [0] => product-category ) [category_id_list] => Array ( [0] => 14 ) [unit_price] => 160 [total_price] => 7200 [taxable_price] => 0 [tax] => 0 [weight] => 0 [shipping] => 0 [sku] => [product_url] => http://xxxxxx [image_id] => [thumbnail_image] => [custom_tax_rate] => [meta] => Array ( [0] => Array ( [wpec_taxes_taxable_amount] => [external_link] => [external_link_text] => [external_link_target] => [no_shipping] => 1 [weight] => 0 [weight_unit] => pound [dimensions] => Array ( [height] => 0 [height_unit] => in [width] => 0 [width_unit] => in [length] => 0 [length_unit] => in ) [shipping] => Array ( [local] => 0 [international] => 0 ) [merchant_notes] => [engraved] => 0 [can_have_uploaded_image] => 0 [enable_comments] => [notify_when_none_left] => 0 [unpublish_when_none_left] => 0 [quantity_limited] => 0 [special] => 0 [display_weight_as] => pound [table_rate_price] => Array ( [quantity] => Array ( ) [table_price] => Array ( ) ) [google_prohibited] => 0 ) ) [is_donation] => 0 [apply_tax] => 1 [priceandstock_id] => 0 [custom_message] => [custom_file] => [comment] => [time_requested] => [file_data] => [is_customisable] => [stock] => [uses_shipping] => 0 [has_limited_stock] => [file_id] => [is_downloadable] => ) [cart_item_count] => 1 [current_cart_item] => 0 [in_the_loop] => 1 [shipping_methods] => [shipping_method] => [shipping_method_count] => 1 [current_shipping_method] => -1 [in_the_method_loop] => [shipping_quotes] => [shipping_quote] => [shipping_quote_count] => 0 [current_shipping_quote] => -1 [in_the_quote_loop] => [coupons_name] => [coupons_amount] => 0 [shipping_option] => ) 45

    http://wordpress.org/plugins/wp-e-commerce/

  2. ababra
    Member
    Posted 1 year ago #

    Upon thinking about this further, I just realized that this is a terrible idea! Even if you override the quantity, the total price will be way off!

    Any suggestions how to achieve this?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.