Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Contribute to GitLab
  • Sign in
W
woocommerce_bpd
  • Project
    • Project
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 8
    • Issues 8
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • wordpress
  • woocommerce_bpd
  • Issues
  • #1

Closed
Open
Opened 10 years ago by Franco (nextime) Lanza@nextime
  • Report abuse
  • New issue
Report abuse New issue

Add product with an product addon programatically

Created by: johncarter-

Hi

First, thanks for putting this up, this is a great plugin and your modifications have made it nearly perfect for my use.

I have one question, how would I go about using this plugin to add a product to cart programtically? Is it even possible? I know that Woocommerce has the ability to add products like so:

public function add_to_cart( $product_id, $quantity, $variation_id = '', $variation = '', $cart_item_data = array() ) {

How would the product add ons be parsed in this function?

Please solve the reCAPTCHA

We want to be sure it is you, please confirm you are not a robot.

  • Franco (nextime) Lanza
    Franco (nextime) Lanza @nextime commented 10 years ago
    Owner

    Created by: nextime

    Hi John, i really never tried to do that, but it's something i will need to do soon, so, i assume i have to test your use..

  • Franco (nextime) Lanza
    Franco (nextime) Lanza @nextime commented 9 years ago
    Owner

    Created by: valix85

    i need some help, i try to catch a product from my cart, i remove it for add it with some addons, a new product is inside a cart with addons array but in cart page i see only my variable product without any addons... i can to do for add many addons in my item cart?

  • Franco (nextime) Lanza
    Franco (nextime) Lanza @nextime commented 9 years ago
    Owner

    Created by: valix85

    My trick for only custom field is: in class-product-addon-cart.php at the start paste it:

    //valerio i23 if ( isset($_GET['add-to-cart']) and is_numeric($_GET['add-to-cart'])){ $_POST = $_GET; } //fine valerio i23

    and next do an ajax call in GET with all parameters addon- example:

    http://www.example.local/cart/?add-to-cart=8&variation_id=83&attribute_pa_posizione=forno-a-destra&attribute_pa_colore-top=top-109&attribute_pa_colore-ante=anta-01&attribute_pa_maniglia=maniglia-1&addon-8-misura-elemento-a-cm=90&addon-8-misura-elemento-b-cm=45

  • Franco (nextime) Lanza
    Franco (nextime) Lanza @nextime commented 9 years ago
    Owner

    Created by: nextime

    Make sense, can you send a pull request with your changes ( ajax part included )?

Please register or sign in to reply
Assignee
No assignee
Assign to
None
Milestone
None
Assign milestone
None
Time tracking
No estimate or time spent
None
Due date
No due date
0
Labels
None
Assign labels
  • View project labels
Confidentiality
Not confidential
Lock issue
Unlocked
1
1 participant
user avatar
Franco (nextime) Lanza
Reference: wordpress/woocommerce_bpd#1