Scroll
Drupal Commerce: Programmatische Ausgabe der Schaltfläche "In den Warenkorb legen"
Foren
Die Frage ist, ich muss programmatisch die Schaltfläche "In den Warenkorb" im Views-Template ausgeben. Ich mache es nach dem Beispiel http://drupal.org/node/1232470#comment-4801356 und der Dokumentation http://api.drupalcommerce.org/api/Drupal%20Commerce/sites!all!modules!commerce!modules!cart!commerce_cart.module/function/commerce_cart_add_to_cart_form/DC
so:
<?php // Erstelle die Artikel für den Warenkorb $line_item = commerce_line_item_new($view['product']->type, $order_id = 0); $line_item->data['context']['product_ids'] = array($view['product']->product_id); $line_item->quantity = 1; // muss Konfiguration für die Menge erstellen $qty = 1; $form_id = commerce_cart_add_to_cart_form_id(array($view['product']->product_id), $qty); $addtocart_form = drupal_get_form($form_id, $line_item); // wir ändern das Formular, um unsere spezielle Themenfunktion zu verwenden // muss in die Konfiguration verschoben werden $addtocart_form['submit']['#theme'][] = 'vtcommerce_button_small'; $variables['cart'] = render($addtocart_form); ?> Die Schaltfläche wird korrekt angezeigt, aber das Widget zur Hinzufügung von Produktmengen nicht, obwohl $line_item->quantity = 1; und $qty = 1; . Frage: Warum?
- Anmelden oder Registrieren, um Kommentare verfassen zu können